about summary refs log tree commit diff
path: root/compiler/rustc_codegen_gcc/src/gcc_util.rs
diff options
context:
space:
mode:
authorLaurențiu Nicola <lnicola@dend.ro>2024-12-23 11:27:07 +0200
committerLaurențiu Nicola <lnicola@dend.ro>2024-12-23 11:27:07 +0200
commit9420a0b11a5403af2d08f2a2b3ece9d331b538dd (patch)
tree14d045ee9ceb0d2f0121f789571bb01dfd0dea6b /compiler/rustc_codegen_gcc/src/gcc_util.rs
parent214134902f952ff8f1f2b24db6d3f6f531675742 (diff)
parent0eca4dd3205a01dba4bd7b7c140ec370aff03440 (diff)
downloadrust-9420a0b11a5403af2d08f2a2b3ece9d331b538dd.tar.gz
rust-9420a0b11a5403af2d08f2a2b3ece9d331b538dd.zip
Merge from rust-lang/rust
Diffstat (limited to 'compiler/rustc_codegen_gcc/src/gcc_util.rs')
-rw-r--r--compiler/rustc_codegen_gcc/src/gcc_util.rs20
1 files changed, 12 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..058a874501b 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,17 @@ 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.toggle_allowed(&sess.target, enable_disable == '+')
+                        {
+                            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 });
+                        }
                     }
                 }