2024-02-16 20:02:50 +00:00
|
|
|
//@ run-pass
|
2024-03-06 12:19:20 -08:00
|
|
|
//@ needs-threads
|
2016-02-11 12:34:41 +01:00
|
|
|
|
2015-10-31 09:41:21 -07:00
|
|
|
use std::thread;
|
|
|
|
|
|
|
|
struct Foo;
|
|
|
|
|
|
|
|
impl Drop for Foo {
|
|
|
|
fn drop(&mut self) {
|
|
|
|
println!("test2");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
thread_local!(static FOO: Foo = Foo);
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
// Off the main thread due to #28129, be sure to initialize FOO first before
|
|
|
|
// calling `println!`
|
|
|
|
thread::spawn(|| {
|
|
|
|
FOO.with(|_| {});
|
|
|
|
println!("test1");
|
|
|
|
}).join().unwrap();
|
|
|
|
}
|