]> git.lizzy.rs Git - rust.git/blob - src/test/ui/stmt_expr_attrs_no_feature.rs
Rollup merge of #57107 - mjbshaw:thread_local_test, r=nikomatsakis
[rust.git] / src / test / ui / stmt_expr_attrs_no_feature.rs
1 #![feature(custom_attribute)]
2
3 macro_rules! stmt_mac {
4     () => {
5         fn b() {}
6     }
7 }
8
9 fn main() {
10     #[attr]
11     fn a() {}
12
13     #[attr] //~ ERROR attributes on expressions are experimental
14     {
15
16     }
17
18     #[attr]
19     5;
20
21     #[attr]
22     stmt_mac!();
23 }
24
25 // Check that cfg works right
26
27 #[cfg(unset)]
28 fn c() {
29     #[attr]
30     5;
31 }
32
33 #[cfg(not(unset))]
34 fn j() {
35     #[attr]
36     5;
37 }
38
39 #[cfg_attr(not(unset), cfg(unset))]
40 fn d() {
41     #[attr]
42     8;
43 }
44
45 #[cfg_attr(not(unset), cfg(not(unset)))]
46 fn i() {
47     #[attr]
48     8;
49 }
50
51 // check that macro expansion and cfg works right
52
53 macro_rules! item_mac {
54     ($e:ident) => {
55         fn $e() {
56             #[attr]
57             42;
58
59             #[cfg(unset)]
60             fn f() {
61                 #[attr]
62                 5;
63             }
64
65             #[cfg(not(unset))]
66             fn k() {
67                 #[attr]
68                 5;
69             }
70
71             #[cfg_attr(not(unset), cfg(unset))]
72             fn g() {
73                 #[attr]
74                 8;
75             }
76
77             #[cfg_attr(not(unset), cfg(not(unset)))]
78             fn h() {
79                 #[attr]
80                 8;
81             }
82
83         }
84     }
85 }
86
87 item_mac!(e);
88
89 // check that the gate visitor works right:
90
91 extern {
92     #[cfg(unset)]
93     fn x(a: [u8; #[attr] 5]);
94     fn y(a: [u8; #[attr] 5]); //~ ERROR 15701
95 }
96
97 struct Foo;
98 impl Foo {
99     #[cfg(unset)]
100     const X: u8 = #[attr] 5;
101     const Y: u8 = #[attr] 5; //~ ERROR 15701
102 }
103
104 trait Bar {
105     #[cfg(unset)]
106     const X: [u8; #[attr] 5];
107     const Y: [u8; #[attr] 5]; //~ ERROR 15701
108 }
109
110 struct Joyce {
111     #[cfg(unset)]
112     field: [u8; #[attr] 5],
113     field2: [u8; #[attr] 5] //~ ERROR 15701
114 }
115
116 struct Walky(
117     #[cfg(unset)] [u8; #[attr] 5],
118     [u8; #[attr] 5] //~ ERROR 15701
119 );
120
121 enum Mike {
122     Happy(
123         #[cfg(unset)] [u8; #[attr] 5],
124         [u8; #[attr] 5] //~ ERROR 15701
125     ),
126     Angry {
127         #[cfg(unset)]
128         field: [u8; #[attr] 5],
129         field2: [u8; #[attr] 5] //~ ERROR 15701
130     }
131 }
132
133 fn pat() {
134     match 5 {
135         #[cfg(unset)]
136         5 => #[attr] (),
137         6 => #[attr] (), //~ ERROR 15701
138         _ => (),
139     }
140 }