@@ -12,33 +12,31 @@ use crate::{Features, Stability};
12
12
13
13
type GateFn = fn ( & Features ) -> bool ;
14
14
15
- macro_rules! cfg_fn {
16
- ( $field: ident) => {
17
- Features :: $field as GateFn
18
- } ;
19
- }
20
-
21
15
pub type GatedCfg = ( Symbol , Symbol , GateFn ) ;
22
16
23
17
/// `cfg(...)`'s that are feature gated.
24
18
const GATED_CFGS : & [ GatedCfg ] = & [
25
19
// (name in cfg, feature, function to check if the feature is enabled)
26
- ( sym:: overflow_checks, sym:: cfg_overflow_checks, cfg_fn ! ( cfg_overflow_checks) ) ,
27
- ( sym:: ub_checks, sym:: cfg_ub_checks, cfg_fn ! ( cfg_ub_checks) ) ,
28
- ( sym:: target_thread_local, sym:: cfg_target_thread_local, cfg_fn ! ( cfg_target_thread_local) ) ,
20
+ ( sym:: overflow_checks, sym:: cfg_overflow_checks, Features :: cfg_overflow_checks) ,
21
+ ( sym:: ub_checks, sym:: cfg_ub_checks, Features :: cfg_ub_checks) ,
22
+ ( sym:: target_thread_local, sym:: cfg_target_thread_local, Features :: cfg_target_thread_local) ,
29
23
(
30
24
sym:: target_has_atomic_equal_alignment,
31
25
sym:: cfg_target_has_atomic_equal_alignment,
32
- cfg_fn ! ( cfg_target_has_atomic_equal_alignment) ,
33
- ) ,
34
- ( sym:: target_has_atomic_load_store, sym:: cfg_target_has_atomic, cfg_fn ! ( cfg_target_has_atomic) ) ,
35
- ( sym:: sanitize, sym:: cfg_sanitize, cfg_fn ! ( cfg_sanitize) ) ,
36
- ( sym:: version, sym:: cfg_version, cfg_fn ! ( cfg_version) ) ,
37
- ( sym:: relocation_model, sym:: cfg_relocation_model, cfg_fn ! ( cfg_relocation_model) ) ,
38
- ( sym:: sanitizer_cfi_generalize_pointers, sym:: cfg_sanitizer_cfi, cfg_fn ! ( cfg_sanitizer_cfi) ) ,
39
- ( sym:: sanitizer_cfi_normalize_integers, sym:: cfg_sanitizer_cfi, cfg_fn ! ( cfg_sanitizer_cfi) ) ,
26
+ Features :: cfg_target_has_atomic_equal_alignment,
27
+ ) ,
28
+ (
29
+ sym:: target_has_atomic_load_store,
30
+ sym:: cfg_target_has_atomic,
31
+ Features :: cfg_target_has_atomic,
32
+ ) ,
33
+ ( sym:: sanitize, sym:: cfg_sanitize, Features :: cfg_sanitize) ,
34
+ ( sym:: version, sym:: cfg_version, Features :: cfg_version) ,
35
+ ( sym:: relocation_model, sym:: cfg_relocation_model, Features :: cfg_relocation_model) ,
36
+ ( sym:: sanitizer_cfi_generalize_pointers, sym:: cfg_sanitizer_cfi, Features :: cfg_sanitizer_cfi) ,
37
+ ( sym:: sanitizer_cfi_normalize_integers, sym:: cfg_sanitizer_cfi, Features :: cfg_sanitizer_cfi) ,
40
38
// this is consistent with naming of the compiler flag it's for
41
- ( sym:: fmt_debug, sym:: fmt_debug, cfg_fn ! ( fmt_debug) ) ,
39
+ ( sym:: fmt_debug, sym:: fmt_debug, Features :: fmt_debug) ,
42
40
] ;
43
41
44
42
/// Find a gated cfg determined by the `pred`icate which is given the cfg's name.
@@ -220,7 +218,7 @@ macro_rules! gated {
220
218
safety: AttributeSafety :: Unsafe ,
221
219
template: $tpl,
222
220
duplicates: $duplicates,
223
- gate: Gated ( Stability :: Unstable , sym:: $gate, $msg, cfg_fn! ( $gate) ) ,
221
+ gate: Gated ( Stability :: Unstable , sym:: $gate, $msg, Features :: $gate) ,
224
222
}
225
223
} ;
226
224
( unsafe $attr: ident, $typ: expr, $tpl: expr, $duplicates: expr, $encode_cross_crate: expr, $msg: expr $( , ) ?) => {
@@ -231,7 +229,7 @@ macro_rules! gated {
231
229
safety: AttributeSafety :: Unsafe ,
232
230
template: $tpl,
233
231
duplicates: $duplicates,
234
- gate: Gated ( Stability :: Unstable , sym:: $attr, $msg, cfg_fn! ( $attr) ) ,
232
+ gate: Gated ( Stability :: Unstable , sym:: $attr, $msg, Features :: $attr) ,
235
233
}
236
234
} ;
237
235
( $attr: ident, $typ: expr, $tpl: expr, $duplicates: expr, $encode_cross_crate: expr, $gate: ident, $msg: expr $( , ) ?) => {
@@ -242,7 +240,7 @@ macro_rules! gated {
242
240
safety: AttributeSafety :: Normal ,
243
241
template: $tpl,
244
242
duplicates: $duplicates,
245
- gate: Gated ( Stability :: Unstable , sym:: $gate, $msg, cfg_fn! ( $gate) ) ,
243
+ gate: Gated ( Stability :: Unstable , sym:: $gate, $msg, Features :: $gate) ,
246
244
}
247
245
} ;
248
246
( $attr: ident, $typ: expr, $tpl: expr, $duplicates: expr, $encode_cross_crate: expr, $msg: expr $( , ) ?) => {
@@ -253,7 +251,7 @@ macro_rules! gated {
253
251
safety: AttributeSafety :: Normal ,
254
252
template: $tpl,
255
253
duplicates: $duplicates,
256
- gate: Gated ( Stability :: Unstable , sym:: $attr, $msg, cfg_fn! ( $attr) ) ,
254
+ gate: Gated ( Stability :: Unstable , sym:: $attr, $msg, Features :: $attr) ,
257
255
}
258
256
} ;
259
257
}
@@ -282,7 +280,7 @@ macro_rules! rustc_attr {
282
280
safety: AttributeSafety :: Normal ,
283
281
template: $tpl,
284
282
duplicates: $duplicates,
285
- gate: Gated ( Stability :: Unstable , sym:: rustc_attrs, $msg, cfg_fn! ( rustc_attrs) ) ,
283
+ gate: Gated ( Stability :: Unstable , sym:: rustc_attrs, $msg, Features :: rustc_attrs) ,
286
284
}
287
285
} ;
288
286
}
@@ -935,7 +933,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
935
933
Stability :: Unstable ,
936
934
sym:: rustc_attrs,
937
935
"diagnostic items compiler internal support for linting" ,
938
- cfg_fn ! ( rustc_attrs) ,
936
+ Features :: rustc_attrs,
939
937
) ,
940
938
} ,
941
939
gated ! (
0 commit comments