]> git.proxmox.com Git - rustc.git/blame - src/test/ui/threads-sendsync/issue-43733-2.rs
New upstream version 1.67.1+dfsg1
[rustc.git] / src / test / ui / threads-sendsync / issue-43733-2.rs
CommitLineData
2b03887a 1// ignore-wasm32
5869c6ff 2// dont-check-compiler-stderr
3b2f2976
XL
3#![feature(cfg_target_thread_local, thread_local_internals)]
4
5// On platforms *without* `#[thread_local]`, use
6// a custom non-`Sync` type to fake the same error.
7#[cfg(not(target_thread_local))]
8struct Key<T> {
9 _data: std::cell::UnsafeCell<Option<T>>,
dc9dc135 10 _flag: std::cell::Cell<()>,
3b2f2976
XL
11}
12
13#[cfg(not(target_thread_local))]
14impl<T> Key<T> {
15 const fn new() -> Self {
16 Key {
17 _data: std::cell::UnsafeCell::new(None),
dc9dc135 18 _flag: std::cell::Cell::new(()),
3b2f2976
XL
19 }
20 }
21}
22
23#[cfg(target_thread_local)]
24use std::thread::__FastLocalKeyInner as Key;
25
26static __KEY: Key<()> = Key::new();
1b1a35ee 27//~^ ERROR `UnsafeCell<Option<()>>` cannot be shared between threads
dc9dc135 28//~| ERROR cannot be shared between threads safely [E0277]
3b2f2976
XL
29
30fn main() {}