about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbjorn3 <17426603+bjorn3@users.noreply.github.com>2025-02-06 12:09:45 +0000
committerbjorn3 <17426603+bjorn3@users.noreply.github.com>2025-03-07 19:11:13 +0000
commit701bedc323b0314ef6f084ba98ed18327faa36bc (patch)
tree447ae293e9cb286685c766c2c2c3ef0593428d55
parentbe1e0b786df35a535327ed3b1457622e357bae6d (diff)
downloadrust-701bedc323b0314ef6f084ba98ed18327faa36bc.tar.gz
rust-701bedc323b0314ef6f084ba98ed18327faa36bc.zip
Move last remaining Rc test to alloctests
-rw-r--r--library/alloc/src/rc.rs (renamed from library/alloc/src/rc/mod.rs)3
-rw-r--r--library/alloc/src/rc/tests.rs15
-rw-r--r--library/alloctests/tests/rc.rs18
3 files changed, 18 insertions, 18 deletions
diff --git a/library/alloc/src/rc/mod.rs b/library/alloc/src/rc.rs
index 09206c2f8b2..2a4d4f26444 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 35ff6b7d570..00000000000
--- 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 0628011ba68..bb68eb4ac9e 100644
--- a/library/alloctests/tests/rc.rs
+++ b/library/alloctests/tests/rc.rs
@@ -316,6 +316,24 @@ fn weak_self_cyclic() {
 }
 
 #[test]
+fn is_unique() {
+    fn is_unique<T>(this: &Rc<T>) -> 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);
     assert!(Rc::strong_count(&a) == 1);