@@ -5,7 +5,7 @@ use rustc_codegen_ssa::errors::TargetFeatureDisableOrEnable;
55use rustc_data_structures:: fx:: FxHashMap ;
66use rustc_middle:: bug;
77use rustc_session:: Session ;
8- use rustc_target:: target_features:: { RUSTC_SPECIFIC_FEATURES , Stability } ;
8+ use rustc_target:: target_features:: RUSTC_SPECIFIC_FEATURES ;
99use smallvec:: { SmallVec , smallvec} ;
1010
1111use crate :: errors:: {
@@ -94,13 +94,15 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri
9494 } ;
9595 sess. dcx ( ) . emit_warn ( unknown_feature) ;
9696 }
97- Some ( ( _, Stability :: Stable , _) ) => { }
98- Some ( ( _, Stability :: Unstable ( _) , _) ) => {
99- // An unstable feature. Warn about using it.
100- sess. dcx ( ) . emit_warn ( UnstableCTargetFeature { feature } ) ;
101- }
102- Some ( ( _, Stability :: Forbidden { .. } , _) ) => {
103- sess. dcx ( ) . emit_err ( ForbiddenCTargetFeature { feature } ) ;
97+ Some ( ( _, stability, _) ) => {
98+ if let Err ( reason) = stability. compute ( & sess. target ) . allow_toggle ( ) {
99+ sess. dcx ( ) . emit_warn ( ForbiddenCTargetFeature { feature, reason } ) ;
100+ } else if stability. requires_nightly ( ) . is_some ( ) {
101+ // An unstable feature. Warn about using it. (It makes little sense
102+ // to hard-error here since we just warn about fully unknown
103+ // features above).
104+ sess. dcx ( ) . emit_warn ( UnstableCTargetFeature { feature } ) ;
105+ }
104106 }
105107 }
106108
0 commit comments