1 //@ignore-target-windows: Channels on Windows are not supported yet.
2 // FIXME: disallow preemption to work around https://github.com/rust-lang/rust/issues/55005
3 //@compile-flags: -Zmiri-ignore-leaks -Zmiri-preemption-rate=0
5 //! Test that leaking threads works, and that their destructors are not executed.
7 use std::cell::RefCell;
10 impl Drop for LoudDrop {
12 eprintln!("Dropping {}", self.0);
17 static X: RefCell<Option<LoudDrop>> = RefCell::new(None);
21 X.with(|x| *x.borrow_mut() = Some(LoudDrop(0)));
23 // Set up a channel so that we can learn when the other thread initialized `X`
24 // (so that we are sure there is something to drop).
25 let (send, recv) = std::sync::mpsc::channel::<()>();
27 let _detached = std::thread::spawn(move || {
28 X.with(|x| *x.borrow_mut() = Some(LoudDrop(1)));
29 send.send(()).unwrap();
30 std::thread::yield_now();
34 std::thread::yield_now();
36 // Wait until child thread has initialized its `X`.
37 let () = recv.recv().unwrap();