Skip to content

Commit 1c979ad

Browse files
committed
builtin_attrs.rs: simplify cfg_fn.
1 parent 332a77e commit 1c979ad

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/libsyntax/feature_gate/builtin_attrs.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,16 @@ use syntax_pos::Span;
1616
use rustc_data_structures::fx::FxHashMap;
1717
use lazy_static::lazy_static;
1818

19+
type GateFn = fn(&Features) -> bool;
20+
1921
macro_rules! cfg_fn {
20-
($field: ident) => {{
21-
fn f(features: &Features) -> bool {
22-
features.$field
23-
}
24-
f as fn(&Features) -> bool
25-
}}
22+
($field: ident) => {
23+
(|features| { features.$field }) as GateFn
24+
}
2625
}
2726

28-
// cfg(...)'s that are feature gated
29-
const GATED_CFGS: &[(Symbol, Symbol, fn(&Features) -> bool)] = &[
27+
/// `cfg(...)`'s that are feature gated.
28+
const GATED_CFGS: &[(Symbol, Symbol, GateFn)] = &[
3029
// (name in cfg, feature, function to check if the feature is enabled)
3130
(sym::target_thread_local, sym::cfg_target_thread_local, cfg_fn!(cfg_target_thread_local)),
3231
(sym::target_has_atomic, sym::cfg_target_has_atomic, cfg_fn!(cfg_target_has_atomic)),

0 commit comments

Comments
 (0)