@@ -115,16 +115,26 @@ macro_rules! template {
115
115
116
116
macro_rules! ungated {
117
117
( $attr: ident, $typ: expr, $tpl: expr $( , ) ?) => {
118
- ( sym:: $attr, $typ, $tpl, Ungated )
118
+ BuiltinAttribute { name : sym:: $attr, type_ : $typ, template : $tpl, gate : Ungated }
119
119
} ;
120
120
}
121
121
122
122
macro_rules! gated {
123
123
( $attr: ident, $typ: expr, $tpl: expr, $gate: ident, $msg: expr $( , ) ?) => {
124
- ( sym:: $attr, $typ, $tpl, Gated ( Stability :: Unstable , sym:: $gate, $msg, cfg_fn!( $gate) ) )
124
+ BuiltinAttribute {
125
+ name: sym:: $attr,
126
+ type_: $typ,
127
+ template: $tpl,
128
+ gate: Gated ( Stability :: Unstable , sym:: $gate, $msg, cfg_fn!( $gate) ) ,
129
+ }
125
130
} ;
126
131
( $attr: ident, $typ: expr, $tpl: expr, $msg: expr $( , ) ?) => {
127
- ( sym:: $attr, $typ, $tpl, Gated ( Stability :: Unstable , sym:: $attr, $msg, cfg_fn!( $attr) ) )
132
+ BuiltinAttribute {
133
+ name: sym:: $attr,
134
+ type_: $typ,
135
+ template: $tpl,
136
+ gate: Gated ( Stability :: Unstable , sym:: $attr, $msg, cfg_fn!( $attr) ) ,
137
+ }
128
138
} ;
129
139
}
130
140
@@ -143,12 +153,12 @@ macro_rules! rustc_attr {
143
153
)
144
154
} ;
145
155
( $attr: ident, $typ: expr, $tpl: expr, $msg: expr $( , ) ?) => {
146
- (
147
- sym:: $attr,
148
- $typ,
149
- $tpl,
150
- Gated ( Stability :: Unstable , sym:: rustc_attrs, $msg, cfg_fn!( rustc_attrs) ) ,
151
- )
156
+ BuiltinAttribute {
157
+ name : sym:: $attr,
158
+ type_ : $typ,
159
+ template : $tpl,
160
+ gate : Gated ( Stability :: Unstable , sym:: rustc_attrs, $msg, cfg_fn!( rustc_attrs) ) ,
161
+ }
152
162
} ;
153
163
}
154
164
@@ -161,7 +171,12 @@ macro_rules! experimental {
161
171
const IMPL_DETAIL : & str = "internal implementation detail" ;
162
172
const INTERNAL_UNSTABLE : & str = "this is an internal attribute that will never be stable" ;
163
173
164
- pub type BuiltinAttribute = ( Symbol , AttributeType , AttributeTemplate , AttributeGate ) ;
174
+ pub struct BuiltinAttribute {
175
+ pub name : Symbol ,
176
+ pub type_ : AttributeType ,
177
+ pub template : AttributeTemplate ,
178
+ pub gate : AttributeGate ,
179
+ }
165
180
166
181
/// Attributes that have a special meaning to rustc or rustdoc.
167
182
#[ rustfmt:: skip]
@@ -290,18 +305,20 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
290
305
) ,
291
306
292
307
// Plugins:
293
- (
294
- sym:: plugin, CrateLevel , template ! ( List : "name" ) ,
295
- Gated (
308
+ BuiltinAttribute {
309
+ name : sym:: plugin,
310
+ type_ : CrateLevel ,
311
+ template : template ! ( List : "name" ) ,
312
+ gate : Gated (
296
313
Stability :: Deprecated (
297
314
"https://github.com/rust-lang/rust/pull/64675" ,
298
315
Some ( "may be removed in a future compiler version" ) ,
299
316
) ,
300
317
sym:: plugin,
301
318
"compiler plugins are deprecated" ,
302
319
cfg_fn ! ( plugin)
303
- )
304
- ) ,
320
+ ) ,
321
+ } ,
305
322
306
323
// Testing:
307
324
gated ! ( allow_fail, Normal , template!( Word ) , experimental!( allow_fail) ) ,
@@ -497,17 +514,17 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
497
514
lang, Normal , template!( NameValueStr : "name" ) , lang_items,
498
515
"language items are subject to change" ,
499
516
) ,
500
- (
501
- sym:: rustc_diagnostic_item,
502
- Normal ,
503
- template ! ( NameValueStr : "name" ) ,
504
- Gated (
517
+ BuiltinAttribute {
518
+ name : sym:: rustc_diagnostic_item,
519
+ type_ : Normal ,
520
+ template : template ! ( NameValueStr : "name" ) ,
521
+ gate : Gated (
505
522
Stability :: Unstable ,
506
523
sym:: rustc_attrs,
507
524
"diagnostic items compiler internal support for linting" ,
508
525
cfg_fn ! ( rustc_attrs) ,
509
526
) ,
510
- ) ,
527
+ } ,
511
528
gated ! (
512
529
// Used in resolve:
513
530
prelude_import, Normal , template!( Word ) ,
@@ -601,7 +618,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
601
618
] ;
602
619
603
620
pub fn deprecated_attributes ( ) -> Vec < & ' static BuiltinAttribute > {
604
- BUILTIN_ATTRIBUTES . iter ( ) . filter ( |( .. , gate ) | gate. is_deprecated ( ) ) . collect ( )
621
+ BUILTIN_ATTRIBUTES . iter ( ) . filter ( |attr| attr . gate . is_deprecated ( ) ) . collect ( )
605
622
}
606
623
607
624
pub fn is_builtin_attr_name ( name : Symbol ) -> bool {
@@ -612,8 +629,8 @@ pub static BUILTIN_ATTRIBUTE_MAP: SyncLazy<FxHashMap<Symbol, &BuiltinAttribute>>
612
629
SyncLazy :: new ( || {
613
630
let mut map = FxHashMap :: default ( ) ;
614
631
for attr in BUILTIN_ATTRIBUTES . iter ( ) {
615
- if map. insert ( attr. 0 , attr) . is_some ( ) {
616
- panic ! ( "duplicate builtin attribute `{}`" , attr. 0 ) ;
632
+ if map. insert ( attr. name , attr) . is_some ( ) {
633
+ panic ! ( "duplicate builtin attribute `{}`" , attr. name ) ;
617
634
}
618
635
}
619
636
map
0 commit comments