diff options
| author | Ralf Jung <post@ralfj.de> | 2024-11-16 10:00:16 +0100 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2024-12-11 22:11:15 +0100 |
| commit | 2d887a5c5ca65287bb40dc5b2d108e2bb2dd6719 (patch) | |
| tree | af562288d549ff410de0ed4bd055d3fb6ba17279 /compiler/rustc_codegen_gcc/src/gcc_util.rs | |
| parent | 1f3bf231e160b9869e2a85260fd6805304bfcee2 (diff) | |
| download | rust-2d887a5c5ca65287bb40dc5b2d108e2bb2dd6719.tar.gz rust-2d887a5c5ca65287bb40dc5b2d108e2bb2dd6719.zip | |
generalize 'forbidden feature' concept so that even (un)stable feature can be invalid to toggle
Also rename some things for extra clarity
Diffstat (limited to 'compiler/rustc_codegen_gcc/src/gcc_util.rs')
| -rw-r--r-- | compiler/rustc_codegen_gcc/src/gcc_util.rs | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/compiler/rustc_codegen_gcc/src/gcc_util.rs b/compiler/rustc_codegen_gcc/src/gcc_util.rs index 65279c9495a..3717e12020f 100644 --- a/compiler/rustc_codegen_gcc/src/gcc_util.rs +++ b/compiler/rustc_codegen_gcc/src/gcc_util.rs @@ -5,7 +5,7 @@ use rustc_codegen_ssa::errors::TargetFeatureDisableOrEnable; use rustc_data_structures::fx::FxHashMap; use rustc_middle::bug; use rustc_session::Session; -use rustc_target::target_features::{RUSTC_SPECIFIC_FEATURES, Stability}; +use rustc_target::target_features::RUSTC_SPECIFIC_FEATURES; use smallvec::{SmallVec, smallvec}; use crate::errors::{ @@ -94,13 +94,15 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri }; sess.dcx().emit_warn(unknown_feature); } - Some((_, Stability::Stable, _)) => {} - Some((_, Stability::Unstable(_), _)) => { - // An unstable feature. Warn about using it. - sess.dcx().emit_warn(UnstableCTargetFeature { feature }); - } - Some((_, Stability::Forbidden { .. }, _)) => { - sess.dcx().emit_err(ForbiddenCTargetFeature { feature }); + Some((_, stability, _)) => { + if let Err(reason) = stability.compute(&sess.target).allow_toggle() { + sess.dcx().emit_warn(ForbiddenCTargetFeature { feature, reason }); + } else if stability.requires_nightly().is_some() { + // An unstable feature. Warn about using it. (It makes little sense + // to hard-error here since we just warn about fully unknown + // features above). + sess.dcx().emit_warn(UnstableCTargetFeature { feature }); + } } } |
