From 29db81de64ca0fa91726125e01b2948dbcaafba0 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Wed, 17 Jul 2024 11:30:36 -0700 Subject: [PATCH] Fix dead code warnings in tests Signed-off-by: Anders Kaseorg --- gc/tests/finalize.rs | 2 +- gc/tests/from_box.rs | 7 ++++++- gc/tests/ignore_trace.rs | 2 +- gc/tests/trace_impl.rs | 11 ++++++----- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/gc/tests/finalize.rs b/gc/tests/finalize.rs index 7df3e16..f717f84 100644 --- a/gc/tests/finalize.rs +++ b/gc/tests/finalize.rs @@ -41,7 +41,7 @@ struct X(Box); 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))); diff --git a/gc/tests/from_box.rs b/gc/tests/from_box.rs index 567b7b5..3e15b47 100644 --- a/gc/tests/from_box.rs +++ b/gc/tests/from_box.rs @@ -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] diff --git a/gc/tests/ignore_trace.rs b/gc/tests/ignore_trace.rs index 5fe0e69..5b0d718 100644 --- a/gc/tests/ignore_trace.rs +++ b/gc/tests/ignore_trace.rs @@ -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(); } diff --git a/gc/tests/trace_impl.rs b/gc/tests/trace_impl.rs index ee6bdc7..4845db5 100644 --- a/gc/tests/trace_impl.rs +++ b/gc/tests/trace_impl.rs @@ -34,11 +34,6 @@ struct InnerBoxStr { inner: Box, } -#[derive(Trace, Clone, Finalize)] -struct InnerRcSlice { - inner: Box<[u32]>, -} - #[derive(Trace, Clone, Finalize)] struct InnerRcStr { inner: Rc, @@ -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();