]> git.lizzy.rs Git - rust.git/commitdiff
builtin_attrs.rs: simplify `cfg_fn`.
authorMazdak Farrokhzad <twingoow@gmail.com>
Thu, 22 Aug 2019 16:37:28 +0000 (18:37 +0200)
committerMazdak Farrokhzad <twingoow@gmail.com>
Thu, 22 Aug 2019 23:39:59 +0000 (01:39 +0200)
src/libsyntax/feature_gate/builtin_attrs.rs

index 17e58df89e1371edd891f860a32e02bef8468858..7cd295b1b2cbf6c5725a52ca4afcb22921e5b361 100644 (file)
 use rustc_data_structures::fx::FxHashMap;
 use lazy_static::lazy_static;
 
+type GateFn = fn(&Features) -> bool;
+
 macro_rules! cfg_fn {
-    ($field: ident) => {{
-        fn f(features: &Features) -> bool {
-            features.$field
-        }
-        f as fn(&Features) -> bool
-    }}
+    ($field: ident) => {
+        (|features| { features.$field }) as GateFn
+    }
 }
 
-// cfg(...)'s that are feature gated
-const GATED_CFGS: &[(Symbol, Symbol, fn(&Features) -> bool)] = &[
+/// `cfg(...)`'s that are feature gated.
+const GATED_CFGS: &[(Symbol, Symbol, GateFn)] = &[
     // (name in cfg, feature, function to check if the feature is enabled)
     (sym::target_thread_local, sym::cfg_target_thread_local, cfg_fn!(cfg_target_thread_local)),
     (sym::target_has_atomic, sym::cfg_target_has_atomic, cfg_fn!(cfg_target_has_atomic)),