]>
Commit | Line | Data |
---|---|---|
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 | |
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 | } |