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