]> git.lizzy.rs Git - rust.git/blob - src/test/ui/lto-still-runs-thread-dtors.rs
Auto merge of #75936 - sdroege:chunks-exact-construction-bounds-check, r=nagisa
[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
6 use std::thread;
7
8 static mut HIT: usize = 0;
9
10 thread_local!(static A: Foo = Foo);
11
12 struct Foo;
13
14 impl Drop for Foo {
15     fn drop(&mut self) {
16         unsafe {
17             HIT += 1;
18         }
19     }
20 }
21
22 fn main() {
23     unsafe {
24         assert_eq!(HIT, 0);
25         thread::spawn(|| {
26             assert_eq!(HIT, 0);
27             A.with(|_| ());
28             assert_eq!(HIT, 0);
29         }).join().unwrap();
30         assert_eq!(HIT, 1);
31     }
32 }