summaryrefslogtreecommitdiffstats
path: root/library/std/src/sync/mpsc/sync_tests.rs
diff options
context:
space:
mode:
Diffstat (limited to 'library/std/src/sync/mpsc/sync_tests.rs')
-rw-r--r--library/std/src/sync/mpsc/sync_tests.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/library/std/src/sync/mpsc/sync_tests.rs b/library/std/src/sync/mpsc/sync_tests.rs
index 9d2f92ffc..632709fd9 100644
--- a/library/std/src/sync/mpsc/sync_tests.rs
+++ b/library/std/src/sync/mpsc/sync_tests.rs
@@ -1,5 +1,6 @@
use super::*;
use crate::env;
+use crate::rc::Rc;
use crate::sync::mpmc::SendTimeoutError;
use crate::thread;
use crate::time::Duration;
@@ -656,3 +657,15 @@ fn issue_15761() {
repro()
}
}
+
+#[test]
+fn drop_unreceived() {
+ let (tx, rx) = sync_channel::<Rc<()>>(1);
+ let msg = Rc::new(());
+ let weak = Rc::downgrade(&msg);
+ assert!(tx.send(msg).is_ok());
+ drop(rx);
+ // Messages should be dropped immediately when the last receiver is destroyed.
+ assert!(weak.upgrade().is_none());
+ drop(tx);
+}