]> git.lizzy.rs Git - rust.git/blob - src/test/ui/threads-sendsync/issue-43733.rs
Pin panic-in-drop=abort test to old pass manager
[rust.git] / src / test / ui / threads-sendsync / issue-43733.rs
1 // revisions: mir thir
2 // [thir]compile-flags: -Z thir-unsafeck
3
4 #![feature(thread_local)]
5 #![feature(cfg_target_thread_local, thread_local_internals)]
6
7 type Foo = std::cell::RefCell<String>;
8
9 #[cfg(target_thread_local)]
10 #[thread_local]
11 static __KEY: std::thread::__FastLocalKeyInner<Foo> = std::thread::__FastLocalKeyInner::new();
12
13 #[cfg(not(target_thread_local))]
14 static __KEY: std::thread::__OsLocalKeyInner<Foo> = std::thread::__OsLocalKeyInner::new();
15
16 fn __getit() -> std::option::Option<&'static Foo> {
17     __KEY.get(Default::default) //~ ERROR call to unsafe function is unsafe
18 }
19
20 static FOO: std::thread::LocalKey<Foo> = std::thread::LocalKey::new(__getit);
21 //~^ ERROR call to unsafe function is unsafe
22
23 fn main() {
24     FOO.with(|foo| println!("{}", foo.borrow()));
25     std::thread::spawn(|| {
26         FOO.with(|foo| *foo.borrow_mut() += "foo");
27     })
28     .join()
29     .unwrap();
30     FOO.with(|foo| println!("{}", foo.borrow()));
31 }