]> git.lizzy.rs Git - rust.git/blob - src/test/ui/thread-local/non-static.rs
Rollup merge of #102092 - kxxt:patch-1, r=joshtriplett
[rust.git] / src / test / ui / thread-local / non-static.rs
1 // Check that #[thread_local] attribute is rejected on non-static items.
2 #![feature(thread_local)]
3
4 #[thread_local]
5 //~^ ERROR attribute should be applied to a static
6 const A: u32 = 0;
7
8 #[thread_local]
9 //~^ ERROR attribute should be applied to a static
10 fn main() {
11     #[thread_local] || {};
12     //~^ ERROR attribute should be applied to a static
13 }
14
15 struct S {
16     #[thread_local]
17     //~^ ERROR attribute should be applied to a static
18     a: String,
19     b: String,
20 }
21
22 #[thread_local]
23 // Static. OK.
24 static B: u32 = 0;
25
26 extern "C" {
27     #[thread_local]
28     // Foreign static. OK.
29     static C: u32;
30 }