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.
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)
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
17 //~^ ERROR: `start` attribute cannot be used at crate level
19 //~^ ERROR: `repr` attribute cannot be used at crate level
21 //~^ ERROR: `path` attribute cannot be used at crate level
22 #![automatically_derived]
23 //~^ ERROR: `automatically_derived` attribute cannot be used at crate level
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
30 //~^ ERROR: attribute should be applied to function or closure
32 //~^ ERROR attribute should be applied to function or closure
34 //~^ NOTE not a function or closure
36 mod inner { #![inline] }
37 //~^ ERROR attribute should be applied to function or closure
38 //~| NOTE not a function or closure
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>
47 //~^ ERROR attribute should be applied to function or closure
48 //~| NOTE not a function or closure
51 //~^ ERROR attribute should be applied to function or closure
52 //~| NOTE not a function or closure
55 //~^ ERROR attribute should be applied to function or closure
56 //~| NOTE not a function or closure
60 //~^ ERROR attribute should be applied to an `extern crate` item
62 //~^ NOTE not an `extern crate` item
64 mod inner { #![no_link] }
65 //~^ ERROR attribute should be applied to an `extern crate` item
66 //~| NOTE not an `extern crate` item
69 //~^ ERROR attribute should be applied to an `extern crate` item
70 //~| NOTE not an `extern crate` item
73 //~^ ERROR attribute should be applied to an `extern crate` item
74 //~| NOTE not an `extern crate` item
77 //~^ ERROR attribute should be applied to an `extern crate` item
78 //~| NOTE not an `extern crate` item
81 //~^ ERROR attribute should be applied to an `extern crate` item
82 //~| NOTE not an `extern crate` item
85 #[export_name = "2200"]
86 //~^ ERROR attribute should be applied to a free function, impl method or static
88 //~^ NOTE not a free function, impl method or static
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
94 #[export_name = "2200"] fn f() { }
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
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
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
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
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
120 //~^ ERROR: `start` attribute can only be used on functions
122 mod inner { #![start] }
123 //~^ ERROR: `start` attribute can only be used on functions
125 // for `fn f()` case, see feature-gate-start.rs
128 //~^ ERROR: `start` attribute can only be used on functions
131 //~^ ERROR: `start` attribute can only be used on functions
134 //~^ ERROR: `start` attribute can only be used on functions
138 //~^ ERROR: attribute should be applied to a struct, enum, or union
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
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
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
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