builtin_attrs.rs: simplify cfg_fn.

This commit is contained in:
Mazdak Farrokhzad 2019-08-22 18:37:28 +02:00
parent 332a77e621
commit 1c979ad552

View File

@ -16,17 +16,16 @@ use syntax_pos::Span;
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)),