]> git.lizzy.rs Git - rust.git/blob - tests/run-pass/threadleak_ignored.rs
no concurrency on windows
[rust.git] / tests / run-pass / threadleak_ignored.rs
1 // ignore-windows: Concurrency on Windows is not supported yet.
2 // compile-flags: -Zmiri-ignore-leaks
3
4 //! Test that leaking threads works, and that their destructors are not executed.
5
6 use std::cell::RefCell;
7
8 struct LoudDrop(i32);
9 impl Drop for LoudDrop {
10     fn drop(&mut self) {
11         eprintln!("Dropping {}", self.0);
12     }
13 }
14
15 thread_local! {
16     static X: RefCell<Option<LoudDrop>> = RefCell::new(None);
17 }
18
19 fn main() {
20     X.with(|x| *x.borrow_mut() = Some(LoudDrop(0)));
21     
22     let _detached = std::thread::spawn(|| {
23         X.with(|x| *x.borrow_mut() = Some(LoudDrop(1)));
24     });
25 }