@@ -134,6 +134,9 @@ static KNOWN_FEATURES: &'static [(&'static str, &'static str, Status)] = &[
134
134
// Allows using the unsafe_no_drop_flag attribute (unlikely to
135
135
// switch to Accepted; see RFC 320)
136
136
( "unsafe_no_drop_flag" , "1.0.0" , Active ) ,
137
+
138
+ // Allows the use of custom attributes; RFC 572
139
+ ( "custom_attribute" , "1.0.0" , Active )
137
140
] ;
138
141
// (changing above list without updating src/doc/reference.md makes @cmr sad)
139
142
@@ -155,6 +158,43 @@ enum Status {
155
158
156
159
// Attributes that have a special meaning to rustc or rustdoc
157
160
pub static KNOWN_ATTRIBUTES : & ' static [ ( & ' static str , AttributeType ) ] = & [
161
+ // Normal attributes
162
+
163
+ ( "warn" , Normal ) ,
164
+ ( "allow" , Normal ) ,
165
+ ( "forbid" , Normal ) ,
166
+ ( "deny" , Normal ) ,
167
+
168
+ ( "macro_reexport" , Normal ) ,
169
+ ( "macro_use" , Normal ) ,
170
+ ( "plugin" , Normal ) ,
171
+ ( "macro_export" , Normal ) ,
172
+ ( "plugin_registrar" , Normal ) ,
173
+
174
+ ( "cfg" , Normal ) ,
175
+ ( "main" , Normal ) ,
176
+ ( "lang" , Normal ) ,
177
+ ( "start" , Normal ) ,
178
+ ( "test" , Normal ) ,
179
+ ( "bench" , Normal ) ,
180
+ ( "simd" , Normal ) ,
181
+ ( "repr" , Normal ) ,
182
+ ( "path" , Normal ) ,
183
+ ( "staged_api" , Normal ) ,
184
+ ( "abi" , Normal ) ,
185
+ ( "rustc_move_fragments" , Normal ) ,
186
+ ( "rustc_variance" , Normal ) ,
187
+ ( "unsafe_destructor" , Normal ) ,
188
+ ( "automatically_derived" , Normal ) ,
189
+ ( "no_mangle" , Normal ) ,
190
+ ( "no_link" , Normal ) ,
191
+ ( "derive" , Normal ) ,
192
+ ( "should_fail" , Normal ) ,
193
+ ( "ignore" , Normal ) ,
194
+ ( "no_implicit_prelude" , Normal ) ,
195
+ ( "reexport_test_harness_main" , Normal ) ,
196
+ ( "link_args" , Normal ) ,
197
+ ( "macro_escape" , Normal ) ,
158
198
159
199
// FIXME: #14408 whitelist docs since rustdoc looks at them
160
200
( "doc" , Whitelisted ) ,
@@ -199,11 +239,13 @@ pub static KNOWN_ATTRIBUTES: &'static [(&'static str, AttributeType)] = &[
199
239
// Crate level attributes
200
240
( "crate_name" , CrateLevel ) ,
201
241
( "crate_type" , CrateLevel ) ,
242
+ ( "crate_id" , CrateLevel ) ,
202
243
( "feature" , CrateLevel ) ,
203
244
( "no_start" , CrateLevel ) ,
204
245
( "no_main" , CrateLevel ) ,
205
246
( "no_std" , CrateLevel ) ,
206
247
( "no_builtins" , CrateLevel ) ,
248
+ ( "recursion_limit" , CrateLevel ) ,
207
249
] ;
208
250
209
251
#[ derive( PartialEq , Copy ) ]
@@ -557,6 +599,18 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
557
599
"unsafe_no_drop_flag has unstable semantics \
558
600
and may be removed in the future") ;
559
601
}
602
+
603
+ // Custom attribute check
604
+ let name = attr. name ( ) ;
605
+
606
+ if KNOWN_ATTRIBUTES . iter ( ) . all ( |& ( n, _) | n != name) {
607
+ self . gate_feature ( "custom_attribute" , attr. span ,
608
+ format ! ( "The attribute `{}` is currently \
609
+ unknown to the the compiler and \
610
+ may have meaning \
611
+ added to it in the future",
612
+ attr. name( ) ) . as_slice ( ) ) ;
613
+ }
560
614
}
561
615
562
616
fn visit_pat ( & mut self , pattern : & ast:: Pat ) {
0 commit comments