]> git.lizzy.rs Git - rust.git/blob - src/test/ui/lto-still-runs-thread-dtors.rs
Auto merge of #84589 - In-line:zircon-thread-name, r=JohnTitor
[rust.git] / src / test / ui / lto-still-runs-thread-dtors.rs
1 // run-pass
2 // compile-flags: -C lto
3 // no-prefer-dynamic
4 // ignore-emscripten no threads support
5 // revisions: mir thir
6 // [thir]compile-flags: -Zthir-unsafeck
7
8 use std::thread;
9
10 static mut HIT: usize = 0;
11
12 thread_local!(static A: Foo = Foo);
13
14 struct Foo;
15
16 impl Drop for Foo {
17     fn drop(&mut self) {
18         unsafe {
19             HIT += 1;
20         }
21     }
22 }
23
24 fn main() {
25     unsafe {
26         assert_eq!(HIT, 0);
27         thread::spawn(|| {
28             assert_eq!(HIT, 0);
29             A.with(|_| ());
30             assert_eq!(HIT, 0);
31         }).join().unwrap();
32         assert_eq!(HIT, 1);
33     }
34 }