1 #![feature(cfg_target_thread_local, thread_local_internals)]
3 // On platforms *without* `#[thread_local]`, use
4 // a custom non-`Sync` type to fake the same error.
5 #[cfg(not(target_thread_local))]
7 _data: std::cell::UnsafeCell<Option<T>>,
8 _flag: std::cell::Cell<()>,
11 #[cfg(not(target_thread_local))]
13 const fn new() -> Self {
15 _data: std::cell::UnsafeCell::new(None),
16 _flag: std::cell::Cell::new(()),
21 #[cfg(target_thread_local)]
22 use std::thread::__FastLocalKeyInner as Key;
24 static __KEY: Key<()> = Key::new();
25 //~^ ERROR `std::cell::UnsafeCell<std::option::Option<()>>` cannot be shared between threads
26 //~| ERROR cannot be shared between threads safely [E0277]