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