target_features: control separately whether enabling and disabling a target feature is allowed

This commit is contained in:
Ralf Jung 2024-11-24 12:22:01 +01:00
parent a1740a9c35
commit eb2e928250
5 changed files with 64 additions and 31 deletions

View file

@ -96,7 +96,7 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri
}
Some((_, stability, _)) => {
if let Err(reason) =
stability.compute_toggleability(&sess.target).allow_toggle()
stability.toggle_allowed(&sess.target, enable_disable == '+')
{
sess.dcx().emit_warn(ForbiddenCTargetFeature { feature, reason });
} else if stability.requires_nightly().is_some() {

View file

@ -483,9 +483,9 @@ fn target_features_cfg(
.rust_target_features()
.iter()
.filter(|(_, gate, _)| gate.in_cfg())
.filter_map(|&(feature, gate, _)| {
.filter_map(|(feature, gate, _)| {
if sess.is_nightly_build() || allow_unstable || gate.requires_nightly().is_none() {
Some(feature)
Some(*feature)
} else {
None
}