1
1
//! Built-in attributes and `cfg` flag gating.
2
2
3
- use AttributeType :: * ;
4
3
use AttributeGate :: * ;
4
+ use AttributeType :: * ;
5
5
6
6
use crate :: { Features , Stability } ;
7
7
8
- use rustc_data_structures:: fx:: FxHashMap ;
9
- use syntax_pos:: symbol:: { Symbol , sym} ;
10
8
use lazy_static:: lazy_static;
9
+ use rustc_data_structures:: fx:: FxHashMap ;
10
+ use syntax_pos:: symbol:: { sym, Symbol } ;
11
11
12
12
type GateFn = fn ( & Features ) -> bool ;
13
13
14
14
macro_rules! cfg_fn {
15
15
( $field: ident) => {
16
- ( |features| { features. $field } ) as GateFn
17
- }
16
+ ( |features| features. $field) as GateFn
17
+ } ;
18
18
}
19
19
20
20
pub type GatedCfg = ( Symbol , Symbol , GateFn ) ;
@@ -66,9 +66,10 @@ pub enum AttributeGate {
66
66
impl std:: fmt:: Debug for AttributeGate {
67
67
fn fmt ( & self , fmt : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
68
68
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" ) ,
72
73
}
73
74
}
74
75
}
@@ -135,22 +136,31 @@ macro_rules! gated {
135
136
macro_rules! rustc_attr {
136
137
( TEST , $attr: ident, $typ: expr, $tpl: expr $( , ) ?) => {
137
138
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 \
140
146
and will never be stable",
141
147
) ,
142
148
)
143
149
} ;
144
150
( $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
+ )
147
157
} ;
148
158
}
149
159
150
160
macro_rules! experimental {
151
161
( $attr: ident) => {
152
162
concat!( "the `#[" , stringify!( $attr) , "]` attribute is an experimental feature" )
153
- }
163
+ } ;
154
164
}
155
165
156
166
const IMPL_DETAIL : & str = "internal implementation detail" ;
@@ -159,6 +169,7 @@ const INTERNAL_UNSTABLE: &str = "this is an internal attribute that will never b
159
169
pub type BuiltinAttribute = ( Symbol , AttributeType , AttributeTemplate , AttributeGate ) ;
160
170
161
171
/// Attributes that have a special meaning to rustc or rustdoc.
172
+ #[ rustfmt:: skip]
162
173
pub const BUILTIN_ATTRIBUTES : & [ BuiltinAttribute ] = & [
163
174
// ==========================================================================
164
175
// Stable attributes:
0 commit comments