]> git.proxmox.com Git - rustc.git/blame - src/test/ui/lto-still-runs-thread-dtors.rs
New upstream version 1.54.0+dfsg1
[rustc.git] / src / test / ui / lto-still-runs-thread-dtors.rs
CommitLineData
416331ca 1// run-pass
ff7c6d11
XL
2// compile-flags: -C lto
3// no-prefer-dynamic
4// ignore-emscripten no threads support
17df50a5
XL
5// revisions: mir thir
6// [thir]compile-flags: -Zthir-unsafeck
ff7c6d11
XL
7
8use std::thread;
9
10static mut HIT: usize = 0;
11
12thread_local!(static A: Foo = Foo);
13
14struct Foo;
15
16impl Drop for Foo {
17 fn drop(&mut self) {
18 unsafe {
19 HIT += 1;
20 }
21 }
22}
23
24fn 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}