diff options
Diffstat (limited to 'tests/ui/threads-sendsync/tls-dtors-are-run-in-a-static-binary.rs')
-rw-r--r-- | tests/ui/threads-sendsync/tls-dtors-are-run-in-a-static-binary.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/ui/threads-sendsync/tls-dtors-are-run-in-a-static-binary.rs b/tests/ui/threads-sendsync/tls-dtors-are-run-in-a-static-binary.rs new file mode 100644 index 000000000..8baef4334 --- /dev/null +++ b/tests/ui/threads-sendsync/tls-dtors-are-run-in-a-static-binary.rs @@ -0,0 +1,22 @@ +// run-pass +// no-prefer-dynamic +// ignore-emscripten no threads support + +static mut HIT: bool = false; + +struct Foo; + +impl Drop for Foo { + fn drop(&mut self) { + unsafe { HIT = true; } + } +} + +thread_local!(static FOO: Foo = Foo); + +fn main() { + std::thread::spawn(|| { + FOO.with(|_| {}); + }).join().unwrap(); + assert!(unsafe { HIT }); +} |