Skip to content

Commit e84d1f2

Browse files
committed
dependency and code updates
update dependencies (including syn, petgraph, indexmap, criterion, etc.), and modernize Cargo.toml formatting
1 parent a09f324 commit e84d1f2

File tree

16 files changed

+105
-91
lines changed

16 files changed

+105
-91
lines changed

README.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# tracing-rc
2-
[![Tests](https://img.shields.io/github/workflow/status/Jesterhearts/tracing-rc/Tests?event=push&style=for-the-badge&label=Tests&logo=github)](https://github.com/Jesterhearts/tracing-rc/actions)
32
[![Crate](https://img.shields.io/crates/v/tracing-rc.svg?style=for-the-badge)](https://crates.io/crates/tracing-rc)
43
[![Docs](https://img.shields.io/docsrs/tracing-rc?style=for-the-badge)](https://docs.rs/tracing-rc)
54

@@ -41,19 +40,19 @@ In order for this crate to be sound and present a safe `Trace` trait, the collec
4140
cause undefined behavior in any of the scenarios outlined. In order to accomplish this, the
4241
collector does the following:
4342
1. Items that are waiting for collection or have been visited during tracing are given an extra
44-
strong or weak reference to make sure the memory remains allocated and the data it contains remains valid
45-
even if strong references are dropped during traversal.
43+
strong or weak reference to make sure the memory remains allocated and the data it contains
44+
remains valid even if strong references are dropped during traversal.
4645
2. Reference counts for traced items are not decremented by the collector during traversal (this is
4746
a difference from e.g. Bacon-Rajan which originally inspired this crate). The collector instead
4847
keeps a count of the number of times it reached each pointer through tracing, and then compares
4948
that count against the strong count for each pointer it traced to decide if the item is dead.
5049
3. Before dropping any values, the collector marks the object dead. During this process, bugs in the
51-
`Trace` implementation may cause the collector to believe a dead value is still alive
52-
(causing a leak) or a live value is dead (making it inaccessible, but leaving the gc pointer
53-
valid). Safe code is unable to access dead values (it will panic or return Option::None), and
54-
cannot restore the live state of a dead object. Values are never temporarily dead, the collector
55-
only marks them dead after it has fully determined that it is a valid candidate for collection
56-
(all strong refs are from members of its cycle).
50+
`Trace` implementation may cause the collector to believe a dead value is still alive (causing a
51+
leak) or a live value is dead (making it inaccessible, but leaving the gc pointer valid). Safe
52+
code is unable to access dead values (it will panic or return Option::None), and cannot restore
53+
the live state of a dead object. Values are never temporarily dead, the collector only marks them
54+
dead after it has fully determined that it is a valid candidate for collection (all strong refs
55+
are from members of its cycle).
5756
4. After the full set of traced objects has been marked, the collector begins dropping the inner
5857
data of objects it believes to be dead, after checking if there are any oustanding borrows
5958
(immutable or mutable). This drop _does not_ and _can not_ free the memory for the gc pointer,
@@ -64,8 +63,8 @@ collector does the following:
6463
reference to the `Gc` value, and its memory will be cleaned up. If there are remaining
6564
references, its memory will be cleaned up when the oustanding references fall out of scope.
6665

67-
There are a decent number number of tests designed to exercise each of these scenarios included, and all
68-
of these tests pass miri (barring leaks for intentionally misbehaved code).
66+
There are a decent number number of tests designed to exercise each of these scenarios included, and
67+
all of these tests pass miri (barring leaks for intentionally misbehaved code).
6968

7069
# Example
7170
```rs

rustfmt.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
wrap_comments = true
2-
comment_width = 100
3-
group_imports = "StdExternalCrate"
4-
imports_layout = "Vertical"
5-
imports_granularity = "Crate"
1+
wrap_comments = true
2+
comment_width = 100
3+
group_imports = "StdExternalCrate"
4+
imports_layout = "Vertical"
5+
imports_granularity = "Crate"
66
format_code_in_doc_comments = true
7-
reorder_impl_items = true
7+
reorder_impl_items = true

tracing-rc-bench/Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
[package]
2-
name = "tracing-rc-bench"
2+
name = "tracing-rc-bench"
33
version = "0.1.0"
44
publish = false
55
edition = "2021"
66

77
[dependencies]
8-
criterion = '^0.3'
8+
criterion = '^0.6'
99

1010
[dependencies.tracing-rc]
11-
path = "../tracing-rc"
11+
path = "../tracing-rc"
1212
features = [ "sync" ]
1313

1414
[[bench]]
15-
name = "minimal_gc"
15+
name = "minimal_gc"
1616
harness = false
1717

1818
[[bench]]
19-
name = "cycle_collection"
20-
harness = false
19+
name = "cycle_collection"
20+
harness = false

tracing-rc-bench/benches/cycle_collection.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
use std::time::{
2-
Duration,
3-
Instant,
1+
use std::{
2+
hint::black_box,
3+
time::{
4+
Duration,
5+
Instant,
6+
},
47
};
58

69
use criterion::{
7-
black_box,
810
criterion_group,
911
criterion_main,
1012
BenchmarkId,

tracing-rc-bench/benches/minimal_gc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use std::{
2+
hint::black_box,
23
rc::Rc,
34
time::{
45
Duration,
@@ -7,7 +8,6 @@ use std::{
78
};
89

910
use criterion::{
10-
black_box,
1111
criterion_group,
1212
criterion_main,
1313
BenchmarkId,

tracing-rc-derive/Cargo.toml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
[package]
2-
name = "tracing-rc-derive"
2+
name = "tracing-rc-derive"
33
description = "Attribute macros for tracing-rc"
4-
version = "0.1.1"
5-
edition = "2021"
6-
license = "MIT OR Apache-2.0"
7-
repository = "https://github.com/Jesterhearts/tracing-rc"
4+
version = "0.2.0"
5+
edition = "2021"
6+
license = "MIT OR Apache-2.0"
7+
repository = "https://github.com/Jesterhearts/tracing-rc"
88

99
[lib]
1010
proc-macro = true
1111

1212
[features]
13-
sync = []
13+
sync = [ ]
1414

1515
[dependencies]
16-
proc-macro2 = '^1.0'
17-
quote = '^1.0'
18-
syn = '^1.0'
19-
synstructure = '^0.12'
16+
proc-macro2 = '^1.0'
17+
quote = '^1.0'
18+
syn = '^2.0'
19+
synstructure = '^0.13'
2020

2121
[dev-dependencies]
2222
trybuild = '^1.0'
2323

2424
[dev-dependencies.tracing-rc]
25-
path = "../tracing-rc"
26-
features = [ "sync" ]
25+
path = "../tracing-rc"
26+
features = [ "sync" ]

tracing-rc-derive/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ fn filter_default_and_ignored_fields(
2020
let mut should_keep = true;
2121

2222
for attr in bi.ast().attrs.iter() {
23-
should_keep = if attr.path.is_ident(TRACE_FIELD_IDENT) {
23+
should_keep = if attr.path().is_ident(TRACE_FIELD_IDENT) {
2424
match attr.parse_args() {
2525
Err(_) => true,
2626
Ok(syn::Meta::Path(path)) => {
@@ -70,7 +70,7 @@ fn filter_specific_fields(specific_fields: &mut synstructure::Structure) -> bool
7070
let mut has_specific_field = false;
7171
specific_fields.filter(|bi| {
7272
if bi.ast().attrs.iter().any(|attr| {
73-
attr.path.is_ident(TRACE_FIELD_IDENT) && attr.parse_args::<syn::Meta>().is_err()
73+
attr.path().is_ident(TRACE_FIELD_IDENT) && attr.parse_args::<syn::Meta>().is_err()
7474
}) {
7575
has_specific_field = true;
7676
true

tracing-rc-fuzz/Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
2-
name = "tracing-rc-fuzz"
3-
version = "0.1.0"
2+
name = "tracing-rc-fuzz"
3+
version = "0.2.0"
44
authors = [ "Automatically generated" ]
55
publish = false
66
edition = "2021"
@@ -9,10 +9,10 @@ edition = "2021"
99
cargo-fuzz = true
1010

1111
[dependencies]
12-
arbitrary = { version = '1', features = [ "derive" ] }
13-
indoc = '^1.0'
12+
arbitrary = { version = '1', features = [ "derive" ] }
13+
indoc = '2'
1414
libfuzzer-sys = '0.4'
15-
petgraph = '^0.6'
15+
petgraph = '0.8'
1616

1717
[dependencies.tracing-rc]
1818
path = "../tracing-rc"
@@ -25,4 +25,4 @@ members = [ "." ]
2525
name = "random_graph"
2626
path = "fuzz_targets/random_graph.rs"
2727
test = false
28-
doc = false
28+
doc = false

tracing-rc/Cargo.toml

Lines changed: 24 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,34 @@
11
[package]
2-
name = "tracing-rc"
2+
name = "tracing-rc"
33
description = "Cycle-aware reference-counted pointers with a safe, simple api"
4-
version = "0.1.3"
5-
edition = "2021"
6-
license = "MIT OR Apache-2.0"
7-
repository = "https://github.com/Jesterhearts/tracing-rc"
8-
readme = "../README.md"
4+
version = "0.2.0"
5+
edition = "2021"
6+
license = "MIT OR Apache-2.0"
7+
repository = "https://github.com/Jesterhearts/tracing-rc"
8+
readme = "../README.md"
99

1010
[features]
11-
default = [ "proc_macro" ]
11+
default = [ "proc_macro" ]
1212
proc_macro = [ "tracing-rc-derive" ]
13-
sync = [ "atomic", "once_cell", "dashmap", "parking_lot", "tracing-rc-derive/sync" ]
13+
sync = [ "atomic", "bytemuck", "once_cell", "dashmap", "parking_lot", "tracing-rc-derive/sync" ]
14+
# Enables the nightly `doc_auto_cfg` feature.
15+
ENABLE_DOC_AUTO_CFG = [ ]
1416

1517
[dependencies]
16-
indexmap = '^1.0'
17-
petgraph = '^0.6'
18+
atomic = { version = '0.6', optional = true }
19+
bytemuck = { version = "1", optional = true, features = [ "derive" ] }
20+
dashmap = { version = '6', optional = true }
21+
indexmap = '2'
22+
once_cell = { version = '1', optional = true }
23+
parking_lot = { version = '0.12', optional = true }
24+
petgraph = '0.8'
25+
tracing-rc-derive = { path = "../tracing-rc-derive", version = "0.2.0", optional = true }
1826

19-
[dependencies.atomic]
20-
version = '^0.5'
21-
optional = true
22-
23-
[dependencies.dashmap]
24-
version = '^5.0'
25-
optional = true
26-
27-
[dependencies.once_cell]
28-
version = '^1.0'
29-
optional = true
30-
31-
[dependencies.parking_lot]
32-
version = '^0.11'
33-
optional = true
27+
[dev-dependencies]
28+
pretty_assertions = '1'
3429

35-
[dependencies.tracing-rc-derive]
36-
path = "../tracing-rc-derive"
37-
version = '^0.1.1'
38-
optional = true
30+
[build-dependencies]
31+
rustc_version = '0.4'
3932

40-
[dev-dependencies]
41-
pretty_assertions = '^1.0'
33+
[package.metadata.docs.rs]
34+
all-features = true

tracing-rc/build.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
use rustc_version::{
2+
version_meta,
3+
Channel,
4+
};
5+
6+
fn main() {
7+
println!("cargo::rustc-check-cfg=cfg(ENABLE_DOC_AUTO_CFG)");
8+
let enable_doc_auto_cfg = match version_meta().unwrap().channel {
9+
Channel::Nightly => "ENABLE_DOC_AUTO_CFG",
10+
_ => "DISABLE_DOC_AUTO_CFG",
11+
};
12+
println!("cargo:rustc-cfg={}", enable_doc_auto_cfg);
13+
}

0 commit comments

Comments
 (0)