]> git.lizzy.rs Git - rust.git/blob - src/test/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.rs
parser will not give wrong help message for 'public'
[rust.git] / src / test / ui / feature-gates / issue-43106-gating-of-builtin-attrs-error.rs
1 //~ NOTE: not an `extern crate` item
2 //~^ NOTE: not a free function, impl method or static
3 //~^^ NOTE: not a function or closure
4 // This is testing whether various builtin attributes signals an
5 // error or warning when put in "weird" places.
6 //
7 // (This file sits on its own because it actually signals an error,
8 // which would mess up the treatment of other cases in
9 // issue-43106-gating-of-builtin-attrs.rs)
10
11
12 #![macro_export]
13 //~^ ERROR: `macro_export` attribute cannot be used at crate level
14 #![rustc_main] //~ ERROR: the `#[rustc_main]` attribute is used internally to specify
15 //~^ ERROR: `rustc_main` attribute cannot be used at crate level
16 #![start]
17 //~^ ERROR: `start` attribute cannot be used at crate level
18 #![repr()]
19 //~^ ERROR: `repr` attribute cannot be used at crate level
20 #![path = "3800"]
21 //~^ ERROR: `path` attribute cannot be used at crate level
22 #![automatically_derived]
23 //~^ ERROR: `automatically_derived` attribute cannot be used at crate level
24 #![no_mangle]
25 #![no_link]
26 //~^ ERROR: attribute should be applied to an `extern crate` item
27 #![export_name = "2200"]
28 //~^ ERROR: attribute should be applied to a free function, impl method or static
29 #![inline]
30 //~^ ERROR: attribute should be applied to function or closure
31 #[inline]
32 //~^ ERROR attribute should be applied to function or closure
33 mod inline {
34     //~^ NOTE not a function or closure
35
36     mod inner { #![inline] }
37     //~^ ERROR attribute should be applied to function or closure
38     //~| NOTE not a function or closure
39
40     #[inline = "2100"] fn f() { }
41     //~^ ERROR attribute must be of the form
42     //~| WARN this was previously accepted
43     //~| NOTE #[deny(ill_formed_attribute_input)]` on by default
44     //~| NOTE for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
45
46     #[inline] struct S;
47     //~^ ERROR attribute should be applied to function or closure
48     //~| NOTE not a function or closure
49
50     #[inline] type T = S;
51     //~^ ERROR attribute should be applied to function or closure
52     //~| NOTE not a function or closure
53
54     #[inline] impl S { }
55     //~^ ERROR attribute should be applied to function or closure
56     //~| NOTE not a function or closure
57 }
58
59 #[no_link]
60 //~^ ERROR attribute should be applied to an `extern crate` item
61 mod no_link {
62     //~^ NOTE not an `extern crate` item
63
64     mod inner { #![no_link] }
65     //~^ ERROR attribute should be applied to an `extern crate` item
66     //~| NOTE not an `extern crate` item
67
68     #[no_link] fn f() { }
69     //~^ ERROR attribute should be applied to an `extern crate` item
70     //~| NOTE not an `extern crate` item
71
72     #[no_link] struct S;
73     //~^ ERROR attribute should be applied to an `extern crate` item
74     //~| NOTE not an `extern crate` item
75
76     #[no_link]type T = S;
77     //~^ ERROR attribute should be applied to an `extern crate` item
78     //~| NOTE not an `extern crate` item
79
80     #[no_link] impl S { }
81     //~^ ERROR attribute should be applied to an `extern crate` item
82     //~| NOTE not an `extern crate` item
83 }
84
85 #[export_name = "2200"]
86 //~^ ERROR attribute should be applied to a free function, impl method or static
87 mod export_name {
88     //~^ NOTE not a free function, impl method or static
89
90     mod inner { #![export_name="2200"] }
91     //~^ ERROR attribute should be applied to a free function, impl method or static
92     //~| NOTE not a free function, impl method or static
93
94     #[export_name = "2200"] fn f() { }
95
96     #[export_name = "2200"] struct S;
97     //~^ ERROR attribute should be applied to a free function, impl method or static
98     //~| NOTE not a free function, impl method or static
99
100     #[export_name = "2200"] type T = S;
101     //~^ ERROR attribute should be applied to a free function, impl method or static
102     //~| NOTE not a free function, impl method or static
103
104     #[export_name = "2200"] impl S { }
105     //~^ ERROR attribute should be applied to a free function, impl method or static
106     //~| NOTE not a free function, impl method or static
107
108     trait Tr {
109         #[export_name = "2200"] fn foo();
110         //~^ ERROR attribute should be applied to a free function, impl method or static
111         //~| NOTE not a free function, impl method or static
112
113         #[export_name = "2200"] fn bar() {}
114         //~^ ERROR attribute should be applied to a free function, impl method or static
115         //~| NOTE not a free function, impl method or static
116     }
117 }
118
119 #[start]
120 //~^ ERROR: `start` attribute can only be used on functions
121 mod start {
122     mod inner { #![start] }
123     //~^ ERROR: `start` attribute can only be used on functions
124
125     // for `fn f()` case, see feature-gate-start.rs
126
127     #[start] struct S;
128     //~^ ERROR: `start` attribute can only be used on functions
129
130     #[start] type T = S;
131     //~^ ERROR: `start` attribute can only be used on functions
132
133     #[start] impl S { }
134     //~^ ERROR: `start` attribute can only be used on functions
135 }
136
137 #[repr(C)]
138 //~^ ERROR: attribute should be applied to a struct, enum, or union
139 mod repr {
140 //~^ NOTE not a struct, enum, or union
141     mod inner { #![repr(C)] }
142     //~^ ERROR: attribute should be applied to a struct, enum, or union
143     //~| NOTE not a struct, enum, or union
144
145     #[repr(C)] fn f() { }
146     //~^ ERROR: attribute should be applied to a struct, enum, or union
147     //~| NOTE not a struct, enum, or union
148
149     struct S;
150
151     #[repr(C)] type T = S;
152     //~^ ERROR: attribute should be applied to a struct, enum, or union
153     //~| NOTE not a struct, enum, or union
154
155     #[repr(C)] impl S { }
156     //~^ ERROR: attribute should be applied to a struct, enum, or union
157     //~| NOTE not a struct, enum, or union
158 }
159
160 fn main() {}