Skip to content

Commit

Permalink
rustc_feature: remove no-longer-needed macro
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Oct 23, 2024
1 parent 0b6207d commit 6de4afd
Showing 1 changed file with 22 additions and 24 deletions.
46 changes: 22 additions & 24 deletions compiler/rustc_feature/src/builtin_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,31 @@ use crate::{Features, Stability};

type GateFn = fn(&Features) -> bool;

macro_rules! cfg_fn {
($field: ident) => {
Features::$field as GateFn
};
}

pub type GatedCfg = (Symbol, Symbol, GateFn);

/// `cfg(...)`'s that are feature gated.
const GATED_CFGS: &[GatedCfg] = &[
// (name in cfg, feature, function to check if the feature is enabled)
(sym::overflow_checks, sym::cfg_overflow_checks, cfg_fn!(cfg_overflow_checks)),
(sym::ub_checks, sym::cfg_ub_checks, cfg_fn!(cfg_ub_checks)),
(sym::target_thread_local, sym::cfg_target_thread_local, cfg_fn!(cfg_target_thread_local)),
(sym::overflow_checks, sym::cfg_overflow_checks, Features::cfg_overflow_checks),
(sym::ub_checks, sym::cfg_ub_checks, Features::cfg_ub_checks),
(sym::target_thread_local, sym::cfg_target_thread_local, Features::cfg_target_thread_local),
(
sym::target_has_atomic_equal_alignment,
sym::cfg_target_has_atomic_equal_alignment,
cfg_fn!(cfg_target_has_atomic_equal_alignment),
),
(sym::target_has_atomic_load_store, sym::cfg_target_has_atomic, cfg_fn!(cfg_target_has_atomic)),
(sym::sanitize, sym::cfg_sanitize, cfg_fn!(cfg_sanitize)),
(sym::version, sym::cfg_version, cfg_fn!(cfg_version)),
(sym::relocation_model, sym::cfg_relocation_model, cfg_fn!(cfg_relocation_model)),
(sym::sanitizer_cfi_generalize_pointers, sym::cfg_sanitizer_cfi, cfg_fn!(cfg_sanitizer_cfi)),
(sym::sanitizer_cfi_normalize_integers, sym::cfg_sanitizer_cfi, cfg_fn!(cfg_sanitizer_cfi)),
Features::cfg_target_has_atomic_equal_alignment,
),
(
sym::target_has_atomic_load_store,
sym::cfg_target_has_atomic,
Features::cfg_target_has_atomic,
),
(sym::sanitize, sym::cfg_sanitize, Features::cfg_sanitize),
(sym::version, sym::cfg_version, Features::cfg_version),
(sym::relocation_model, sym::cfg_relocation_model, Features::cfg_relocation_model),
(sym::sanitizer_cfi_generalize_pointers, sym::cfg_sanitizer_cfi, Features::cfg_sanitizer_cfi),
(sym::sanitizer_cfi_normalize_integers, sym::cfg_sanitizer_cfi, Features::cfg_sanitizer_cfi),
// this is consistent with naming of the compiler flag it's for
(sym::fmt_debug, sym::fmt_debug, cfg_fn!(fmt_debug)),
(sym::fmt_debug, sym::fmt_debug, Features::fmt_debug),
];

/// Find a gated cfg determined by the `pred`icate which is given the cfg's name.
Expand Down Expand Up @@ -220,7 +218,7 @@ macro_rules! gated {
safety: AttributeSafety::Unsafe,
template: $tpl,
duplicates: $duplicates,
gate: Gated(Stability::Unstable, sym::$gate, $msg, cfg_fn!($gate)),
gate: Gated(Stability::Unstable, sym::$gate, $msg, Features::$gate),
}
};
(unsafe $attr:ident, $typ:expr, $tpl:expr, $duplicates:expr, $encode_cross_crate:expr, $msg:expr $(,)?) => {
Expand All @@ -231,7 +229,7 @@ macro_rules! gated {
safety: AttributeSafety::Unsafe,
template: $tpl,
duplicates: $duplicates,
gate: Gated(Stability::Unstable, sym::$attr, $msg, cfg_fn!($attr)),
gate: Gated(Stability::Unstable, sym::$attr, $msg, Features::$attr),
}
};
($attr:ident, $typ:expr, $tpl:expr, $duplicates:expr, $encode_cross_crate:expr, $gate:ident, $msg:expr $(,)?) => {
Expand All @@ -242,7 +240,7 @@ macro_rules! gated {
safety: AttributeSafety::Normal,
template: $tpl,
duplicates: $duplicates,
gate: Gated(Stability::Unstable, sym::$gate, $msg, cfg_fn!($gate)),
gate: Gated(Stability::Unstable, sym::$gate, $msg, Features::$gate),
}
};
($attr:ident, $typ:expr, $tpl:expr, $duplicates:expr, $encode_cross_crate:expr, $msg:expr $(,)?) => {
Expand All @@ -253,7 +251,7 @@ macro_rules! gated {
safety: AttributeSafety::Normal,
template: $tpl,
duplicates: $duplicates,
gate: Gated(Stability::Unstable, sym::$attr, $msg, cfg_fn!($attr)),
gate: Gated(Stability::Unstable, sym::$attr, $msg, Features::$attr),
}
};
}
Expand Down Expand Up @@ -282,7 +280,7 @@ macro_rules! rustc_attr {
safety: AttributeSafety::Normal,
template: $tpl,
duplicates: $duplicates,
gate: Gated(Stability::Unstable, sym::rustc_attrs, $msg, cfg_fn!(rustc_attrs)),
gate: Gated(Stability::Unstable, sym::rustc_attrs, $msg, Features::rustc_attrs),
}
};
}
Expand Down Expand Up @@ -935,7 +933,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
Stability::Unstable,
sym::rustc_attrs,
"diagnostic items compiler internal support for linting",
cfg_fn!(rustc_attrs),
Features::rustc_attrs,
),
},
gated!(
Expand Down

0 comments on commit 6de4afd

Please sign in to comment.