1 //@compile-flags: -Zmiri-ignore-leaks
3 //! Test that leaking threads works, and that their destructors are not executed.
5 use std::cell::RefCell;
8 impl Drop for LoudDrop {
10 eprintln!("Dropping {}", self.0);
15 static X: RefCell<Option<LoudDrop>> = RefCell::new(None);
19 X.with(|x| *x.borrow_mut() = Some(LoudDrop(0)));
21 // Set up a channel so that we can learn when the other thread initialized `X`
22 // (so that we are sure there is something to drop).
23 let (send, recv) = std::sync::mpsc::channel::<()>();
25 let _detached = std::thread::spawn(move || {
26 X.with(|x| *x.borrow_mut() = Some(LoudDrop(1)));
27 send.send(()).unwrap();
28 std::thread::yield_now();
32 std::thread::yield_now();
34 // Wait until child thread has initialized its `X`.
35 let () = recv.recv().unwrap();