]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass-valgrind/down-with-thread-dtors.rs
fix merge conflicts
[rust.git] / src / test / run-pass-valgrind / down-with-thread-dtors.rs
1 // no-prefer-dynamic
2 // ignore-emscripten
3
4 thread_local!(static FOO: Foo = Foo);
5 thread_local!(static BAR: Bar = Bar(1));
6 thread_local!(static BAZ: Baz = Baz);
7
8 static mut HIT: bool = false;
9
10 struct Foo;
11 struct Bar(i32);
12 struct Baz;
13
14 impl Drop for Foo {
15     fn drop(&mut self) {
16         BAR.with(|_| {});
17     }
18 }
19
20 impl Drop for Bar {
21     fn drop(&mut self) {
22         assert_eq!(self.0, 1);
23         self.0 = 2;
24         BAZ.with(|_| {});
25         assert_eq!(self.0, 2);
26     }
27 }
28
29 impl Drop for Baz {
30     fn drop(&mut self) {
31         unsafe { HIT = true; }
32     }
33 }
34
35 fn main() {
36     std::thread::spawn(|| {
37         FOO.with(|_| {});
38     }).join().unwrap();
39     assert!(unsafe { HIT });
40 }