about summary refs log tree commit diff
path: root/library/std/tests
diff options
context:
space:
mode:
authorThe rustc-dev-guide Cronjob Bot <github-actions@github.com>2025-04-19 13:53:12 +0000
committerThe rustc-dev-guide Cronjob Bot <github-actions@github.com>2025-04-19 13:53:12 +0000
commit3b2302ec0d17cbc94ef68b15f0bb6524f8b67f3f (patch)
tree05635b943c977eba01cebf3ef78d8a479e555de5 /library/std/tests
parenta0c64dce0d70d1be54a6fd7b7aa9ed37665ad998 (diff)
parenta7c39b68616668a45f0afd62849a1da7c8ad2516 (diff)
Merge from rustc
Diffstat (limited to 'library/std/tests')
-rw-r--r--library/std/tests/sync/mpmc.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/library/std/tests/sync/mpmc.rs b/library/std/tests/sync/mpmc.rs
index 81b92297f76..78abcb3bcbe 100644
--- a/library/std/tests/sync/mpmc.rs
+++ b/library/std/tests/sync/mpmc.rs
@@ -64,6 +64,24 @@ fn smoke_port_gone() {
 }
 
 #[test]
+fn smoke_receiver_clone() {
+    let (tx, rx) = channel::<i32>();
+    let rx2 = rx.clone();
+    drop(rx);
+    tx.send(1).unwrap();
+    assert_eq!(rx2.recv().unwrap(), 1);
+}
+
+#[test]
+fn smoke_receiver_clone_port_gone() {
+    let (tx, rx) = channel::<i32>();
+    let rx2 = rx.clone();
+    drop(rx);
+    drop(rx2);
+    assert!(tx.send(1).is_err());
+}
+
+#[test]
 fn smoke_shared_port_gone() {
     let (tx, rx) = channel::<i32>();
     drop(rx);
@@ -125,6 +143,18 @@ fn chan_gone_concurrent() {
 }
 
 #[test]
+fn receiver_cloning() {
+    let (tx, rx) = channel::<i32>();
+    let rx2 = rx.clone();
+
+    tx.send(1).unwrap();
+    tx.send(2).unwrap();
+
+    assert_eq!(rx2.recv(), Ok(1));
+    assert_eq!(rx.recv(), Ok(2));
+}
+
+#[test]
 fn stress() {
     let count = if cfg!(miri) { 100 } else { 10000 };
     let (tx, rx) = channel::<i32>();