@@ -5,7 +5,7 @@ use rustc_codegen_ssa::errors::TargetFeatureDisableOrEnable;
5
5
use rustc_data_structures:: fx:: FxHashMap ;
6
6
use rustc_middle:: bug;
7
7
use rustc_session:: Session ;
8
- use rustc_target:: target_features:: { RUSTC_SPECIFIC_FEATURES , Stability } ;
8
+ use rustc_target:: target_features:: RUSTC_SPECIFIC_FEATURES ;
9
9
use smallvec:: { SmallVec , smallvec} ;
10
10
11
11
use crate :: errors:: {
@@ -94,13 +94,15 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri
94
94
} ;
95
95
sess. dcx ( ) . emit_warn ( unknown_feature) ;
96
96
}
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
+ }
104
106
}
105
107
}
106
108
0 commit comments