Skip to content

Commit

Permalink
Fix dead code warnings in tests
Browse files Browse the repository at this point in the history
Signed-off-by: Anders Kaseorg <[email protected]>
  • Loading branch information
andersk committed Jul 17, 2024
1 parent d84eb95 commit 29db81d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 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};
#[cfg(feature = "nightly")]
use gc::{Finalize, Trace};
use gc::Gc;

#[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/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();
}
11 changes: 6 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,12 @@ 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 29db81d

Please sign in to comment.