From 701bedc323b0314ef6f084ba98ed18327faa36bc Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Thu, 6 Feb 2025 12:09:45 +0000 Subject: [PATCH] Move last remaining Rc test to alloctests --- library/alloc/src/{rc/mod.rs => rc.rs} | 3 --- library/alloc/src/rc/tests.rs | 15 --------------- library/alloctests/tests/rc.rs | 18 ++++++++++++++++++ 3 files changed, 18 insertions(+), 18 deletions(-) rename library/alloc/src/{rc/mod.rs => rc.rs} (99%) delete mode 100644 library/alloc/src/rc/tests.rs diff --git a/library/alloc/src/rc/mod.rs b/library/alloc/src/rc.rs similarity index 99% rename from library/alloc/src/rc/mod.rs rename to library/alloc/src/rc.rs index 09206c2f8b29..2a4d4f264444 100644 --- a/library/alloc/src/rc/mod.rs +++ b/library/alloc/src/rc.rs @@ -276,9 +276,6 @@ use crate::string::String; #[cfg(not(no_global_oom_handling))] use crate::vec::Vec; -#[cfg(test)] -mod tests; - // This is repr(C) to future-proof against possible field-reordering, which // would interfere with otherwise safe [into|from]_raw() of transmutable // inner types. diff --git a/library/alloc/src/rc/tests.rs b/library/alloc/src/rc/tests.rs deleted file mode 100644 index 35ff6b7d570d..000000000000 --- a/library/alloc/src/rc/tests.rs +++ /dev/null @@ -1,15 +0,0 @@ -use super::*; - -#[test] -fn is_unique() { - let x = Rc::new(3); - assert!(Rc::is_unique(&x)); - let y = x.clone(); - assert!(!Rc::is_unique(&x)); - drop(y); - assert!(Rc::is_unique(&x)); - let w = Rc::downgrade(&x); - assert!(!Rc::is_unique(&x)); - drop(w); - assert!(Rc::is_unique(&x)); -} diff --git a/library/alloctests/tests/rc.rs b/library/alloctests/tests/rc.rs index 0628011ba682..bb68eb4ac9e3 100644 --- a/library/alloctests/tests/rc.rs +++ b/library/alloctests/tests/rc.rs @@ -315,6 +315,24 @@ fn weak_self_cyclic() { // hopefully we don't double-free (or leak)... } +#[test] +fn is_unique() { + fn is_unique(this: &Rc) -> bool { + Rc::weak_count(this) == 0 && Rc::strong_count(this) == 1 + } + + let x = Rc::new(3); + assert!(is_unique(&x)); + let y = x.clone(); + assert!(!is_unique(&x)); + drop(y); + assert!(is_unique(&x)); + let w = Rc::downgrade(&x); + assert!(!is_unique(&x)); + drop(w); + assert!(is_unique(&x)); +} + #[test] fn test_strong_count() { let a = Rc::new(0);