@@ -115,16 +115,26 @@ macro_rules! template {
115115
116116macro_rules! ungated {
117117 ( $attr: ident, $typ: expr, $tpl: expr $( , ) ?) => {
118- ( sym:: $attr, $typ, $tpl, Ungated )
118+ BuiltinAttribute { name : sym:: $attr, type_ : $typ, template : $tpl, gate : Ungated }
119119 } ;
120120}
121121
122122macro_rules! gated {
123123 ( $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+ }
125130 } ;
126131 ( $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+ }
128138 } ;
129139}
130140
@@ -143,12 +153,12 @@ macro_rules! rustc_attr {
143153 )
144154 } ;
145155 ( $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+ }
152162 } ;
153163}
154164
@@ -161,7 +171,12 @@ macro_rules! experimental {
161171const IMPL_DETAIL : & str = "internal implementation detail" ;
162172const INTERNAL_UNSTABLE : & str = "this is an internal attribute that will never be stable" ;
163173
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+ }
165180
166181/// Attributes that have a special meaning to rustc or rustdoc.
167182#[ rustfmt:: skip]
@@ -290,18 +305,20 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
290305 ) ,
291306
292307 // 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 (
296313 Stability :: Deprecated (
297314 "https://github.com/rust-lang/rust/pull/64675" ,
298315 Some ( "may be removed in a future compiler version" ) ,
299316 ) ,
300317 sym:: plugin,
301318 "compiler plugins are deprecated" ,
302319 cfg_fn ! ( plugin)
303- )
304- ) ,
320+ ) ,
321+ } ,
305322
306323 // Testing:
307324 gated ! ( allow_fail, Normal , template!( Word ) , experimental!( allow_fail) ) ,
@@ -497,17 +514,17 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
497514 lang, Normal , template!( NameValueStr : "name" ) , lang_items,
498515 "language items are subject to change" ,
499516 ) ,
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 (
505522 Stability :: Unstable ,
506523 sym:: rustc_attrs,
507524 "diagnostic items compiler internal support for linting" ,
508525 cfg_fn ! ( rustc_attrs) ,
509526 ) ,
510- ) ,
527+ } ,
511528 gated ! (
512529 // Used in resolve:
513530 prelude_import, Normal , template!( Word ) ,
@@ -601,7 +618,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
601618] ;
602619
603620pub 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 ( )
605622}
606623
607624pub fn is_builtin_attr_name ( name : Symbol ) -> bool {
@@ -612,8 +629,8 @@ pub static BUILTIN_ATTRIBUTE_MAP: SyncLazy<FxHashMap<Symbol, &BuiltinAttribute>>
612629 SyncLazy :: new ( || {
613630 let mut map = FxHashMap :: default ( ) ;
614631 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 ) ;
617634 }
618635 }
619636 map
0 commit comments