11//! Built-in attributes and `cfg` flag gating.
22
3- use AttributeType :: * ;
43use AttributeGate :: * ;
4+ use AttributeType :: * ;
55
66use crate :: { Features , Stability } ;
77
8- use rustc_data_structures:: fx:: FxHashMap ;
9- use syntax_pos:: symbol:: { Symbol , sym} ;
108use lazy_static:: lazy_static;
9+ use rustc_data_structures:: fx:: FxHashMap ;
10+ use syntax_pos:: symbol:: { sym, Symbol } ;
1111
1212type GateFn = fn ( & Features ) -> bool ;
1313
1414macro_rules! cfg_fn {
1515 ( $field: ident) => {
16- ( |features| { features. $field } ) as GateFn
17- }
16+ ( |features| features. $field) as GateFn
17+ } ;
1818}
1919
2020pub type GatedCfg = ( Symbol , Symbol , GateFn ) ;
@@ -66,9 +66,10 @@ pub enum AttributeGate {
6666impl std:: fmt:: Debug for AttributeGate {
6767 fn fmt ( & self , fmt : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
6868 match * self {
69- Self :: Gated ( ref stab, name, expl, _) =>
70- write ! ( fmt, "Gated({:?}, {}, {})" , stab, name, expl) ,
71- Self :: Ungated => write ! ( fmt, "Ungated" )
69+ Self :: Gated ( ref stab, name, expl, _) => {
70+ write ! ( fmt, "Gated({:?}, {}, {})" , stab, name, expl)
71+ }
72+ Self :: Ungated => write ! ( fmt, "Ungated" ) ,
7273 }
7374 }
7475}
@@ -135,22 +136,31 @@ macro_rules! gated {
135136macro_rules! rustc_attr {
136137 ( TEST , $attr: ident, $typ: expr, $tpl: expr $( , ) ?) => {
137138 rustc_attr!(
138- $attr, $typ, $tpl,
139- concat!( "the `#[" , stringify!( $attr) , "]` attribute is just used for rustc unit tests \
139+ $attr,
140+ $typ,
141+ $tpl,
142+ concat!(
143+ "the `#[" ,
144+ stringify!( $attr) ,
145+ "]` attribute is just used for rustc unit tests \
140146 and will never be stable",
141147 ) ,
142148 )
143149 } ;
144150 ( $attr: ident, $typ: expr, $tpl: expr, $msg: expr $( , ) ?) => {
145- ( sym:: $attr, $typ, $tpl,
146- Gated ( Stability :: Unstable , sym:: rustc_attrs, $msg, cfg_fn!( rustc_attrs) ) )
151+ (
152+ sym:: $attr,
153+ $typ,
154+ $tpl,
155+ Gated ( Stability :: Unstable , sym:: rustc_attrs, $msg, cfg_fn!( rustc_attrs) ) ,
156+ )
147157 } ;
148158}
149159
150160macro_rules! experimental {
151161 ( $attr: ident) => {
152162 concat!( "the `#[" , stringify!( $attr) , "]` attribute is an experimental feature" )
153- }
163+ } ;
154164}
155165
156166const IMPL_DETAIL : & str = "internal implementation detail" ;
@@ -159,6 +169,7 @@ const INTERNAL_UNSTABLE: &str = "this is an internal attribute that will never b
159169pub type BuiltinAttribute = ( Symbol , AttributeType , AttributeTemplate , AttributeGate ) ;
160170
161171/// Attributes that have a special meaning to rustc or rustdoc.
172+ #[ rustfmt:: skip]
162173pub const BUILTIN_ATTRIBUTES : & [ BuiltinAttribute ] = & [
163174 // ==========================================================================
164175 // Stable attributes:
0 commit comments