]> git.lizzy.rs Git - rust.git/blob - src/test/compile-fail/issue-43733-2.rs
Rollup merge of #44562 - eddyb:ugh-rustdoc, r=nikomatsakis
[rust.git] / src / test / compile-fail / issue-43733-2.rs
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.
4 //
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.
10
11 #![feature(const_fn, const_cell_new, const_unsafe_cell_new)]
12 #![feature(cfg_target_thread_local, thread_local_internals)]
13
14 // On platforms *without* `#[thread_local]`, use
15 // a custom non-`Sync` type to fake the same error.
16 #[cfg(not(target_thread_local))]
17 struct Key<T> {
18     _data: std::cell::UnsafeCell<Option<T>>,
19     _flag: std::cell::Cell<bool>,
20 }
21
22 #[cfg(not(target_thread_local))]
23 impl<T> Key<T> {
24     const fn new() -> Self {
25         Key {
26             _data: std::cell::UnsafeCell::new(None),
27             _flag: std::cell::Cell::new(false),
28         }
29     }
30 }
31
32 #[cfg(target_thread_local)]
33 use std::thread::__FastLocalKeyInner as Key;
34
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
38
39 fn main() {}