1 // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 #![feature(const_fn, const_cell_new, const_unsafe_cell_new)]
12 #![feature(cfg_target_thread_local, thread_local_internals)]
14 // On platforms *without* `#[thread_local]`, use
15 // a custom non-`Sync` type to fake the same error.
16 #[cfg(not(target_thread_local))]
18 _data: std::cell::UnsafeCell<Option<T>>,
19 _flag: std::cell::Cell<bool>,
22 #[cfg(not(target_thread_local))]
24 const fn new() -> Self {
26 _data: std::cell::UnsafeCell::new(None),
27 _flag: std::cell::Cell::new(false),
32 #[cfg(target_thread_local)]
33 use std::thread::__FastLocalKeyInner as Key;
35 static __KEY: Key<()> = Key::new();
36 //~^ ERROR `std::cell::UnsafeCell<std::option::Option<()>>: std::marker::Sync` is not satisfied
37 //~| ERROR `std::cell::Cell<bool>: std::marker::Sync` is not satisfied