Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dead code warnings in tests #179

Merged
merged 1 commit into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading