Skip to content

Commit

Permalink
Merge pull request #179 from andersk/dead-code
Browse files Browse the repository at this point in the history
Fix dead code warnings in tests
  • Loading branch information
Manishearth authored Jul 17, 2024
2 parents 9738caa + 7195c3b commit 8dd9cf5
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 9 deletions.
2 changes: 1 addition & 1 deletion gc/tests/finalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct X(Box<dyn Trace>);
fn drop_triggers_finalize() {
FLAGS.with(|f| assert_eq!(f.get(), Flags(0, 0)));
{
let _x = A { b: B };
let _x = X(Box::new(A { b: B }));
FLAGS.with(|f| assert_eq!(f.get(), Flags(0, 0)));
}
FLAGS.with(|f| assert_eq!(f.get(), Flags(1, 1)));
Expand Down
7 changes: 6 additions & 1 deletion gc/tests/from_box.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
use gc::{Finalize, Gc, Trace};
use gc::Gc;
#[cfg(feature = "nightly")]
use gc::{Finalize, Trace};

#[cfg(feature = "nightly")]
trait Foo: Trace {}

#[cfg(feature = "nightly")]
#[derive(Trace, Finalize)]
struct Bar;
#[cfg(feature = "nightly")]
impl Foo for Bar {}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion gc/tests/gc_semantics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ fn as_ptr() {
let a_ptr = Gc::as_ptr(&a);
assert_eq!(a_ptr, Gc::as_ptr(&aa));

let b = Gc::new(B(a.clone()));
let b = Gc::new(B(a.clone()));
assert_eq!(a_ptr, Gc::as_ptr(&b.0));
let bb = Gc::new(B(a.clone()));
assert_eq!(a_ptr, Gc::as_ptr(&bb.0));
Expand Down
2 changes: 1 addition & 1 deletion gc/tests/ignore_trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ struct S(#[unsafe_ignore_trace] Gc<()>);
/// cycles through that `Gc`, but it should not result in panics.
#[test]
fn ignore_trace_gc() {
Gc::new(S(Gc::new(())));
*Gc::new(S(Gc::new(()))).0;
force_collect();
}
20 changes: 15 additions & 5 deletions gc/tests/trace_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ struct InnerBoxStr {
inner: Box<str>,
}

#[derive(Trace, Clone, Finalize)]
struct InnerRcSlice {
inner: Box<[u32]>,
}

#[derive(Trace, Clone, Finalize)]
struct InnerRcStr {
inner: Rc<str>,
Expand All @@ -52,6 +47,21 @@ struct Baz {

#[test]
fn test() {
unsafe {
InnerBoxSlice {
inner: Box::new([1, 2, 3]),
}
.trace();
InnerBoxStr {
inner: "abc".into(),
}
.trace();
InnerRcStr {
inner: "abc".into(),
}
.trace();
}

let bar = Bar { inner: Foo };
unsafe {
bar.trace();
Expand Down

0 comments on commit 8dd9cf5

Please sign in to comment.