@@ -28,7 +28,12 @@ pub enum Stability {
2828 /// set in the target spec. It is never set in `cfg(target_feature)`. Used in
2929 /// particular for features are actually ABI configuration flags (not all targets are as nice as
3030 /// RISC-V and have an explicit way to set the ABI separate from target features).
31- Forbidden { reason : & ' static str } ,
31+ Forbidden {
32+ reason : & ' static str ,
33+ /// True if this is always an error, false if this can be reported as a warning when set via
34+ /// `-Ctarget-feature`.
35+ hard_error : bool ,
36+ } ,
3237}
3338use Stability :: * ;
3439
@@ -41,8 +46,9 @@ impl<CTX> HashStable<CTX> for Stability {
4146 Stability :: Unstable ( nightly_feature) => {
4247 nightly_feature. hash_stable ( hcx, hasher) ;
4348 }
44- Stability :: Forbidden { reason } => {
49+ Stability :: Forbidden { reason, hard_error } => {
4550 reason. hash_stable ( hcx, hasher) ;
51+ hard_error. hash_stable ( hcx, hasher) ;
4652 }
4753 }
4854 }
@@ -73,12 +79,12 @@ impl Stability {
7379 }
7480
7581 /// Returns whether the feature may be toggled via `#[target_feature]` or `-Ctarget-feature`.
76- /// (It might still be nightly-only even if this returns `true `, so make sure to also check
82+ /// (It might still be nightly-only even if this returns `Ok(()) `, so make sure to also check
7783 /// `requires_nightly`.)
7884 pub fn toggle_allowed ( & self ) -> Result < ( ) , & ' static str > {
7985 match self {
8086 Stability :: Unstable ( _) | Stability :: Stable { .. } => Ok ( ( ) ) ,
81- Stability :: Forbidden { reason } => Err ( reason) ,
87+ Stability :: Forbidden { reason, hard_error : _ } => Err ( reason) ,
8288 }
8389 }
8490}
@@ -135,7 +141,10 @@ static ARM_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
135141 ( "aes" , Unstable ( sym:: arm_target_feature) , & [ "neon" ] ) ,
136142 (
137143 "atomics-32" ,
138- Stability :: Forbidden { reason : "unsound because it changes the ABI of atomic operations" } ,
144+ Stability :: Forbidden {
145+ reason : "unsound because it changes the ABI of atomic operations" ,
146+ hard_error : false ,
147+ } ,
139148 & [ ] ,
140149 ) ,
141150 ( "crc" , Unstable ( sym:: arm_target_feature) , & [ ] ) ,
@@ -211,7 +220,11 @@ static AARCH64_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
211220 // FEAT_FLAGM2
212221 ( "flagm2" , Unstable ( sym:: aarch64_unstable_target_feature) , & [ ] ) ,
213222 // We forbid directly toggling just `fp-armv8`; it must be toggled with `neon`.
214- ( "fp-armv8" , Stability :: Forbidden { reason : "Rust ties `fp-armv8` to `neon`" } , & [ ] ) ,
223+ (
224+ "fp-armv8" ,
225+ Stability :: Forbidden { reason : "Rust ties `fp-armv8` to `neon`" , hard_error : false } ,
226+ & [ ] ,
227+ ) ,
215228 // FEAT_FP8
216229 ( "fp8" , Unstable ( sym:: aarch64_unstable_target_feature) , & [ "faminmax" , "lut" , "bf16" ] ) ,
217230 // FEAT_FP8DOT2
@@ -274,7 +287,11 @@ static AARCH64_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
274287 ( "rcpc3" , Unstable ( sym:: aarch64_unstable_target_feature) , & [ "rcpc2" ] ) ,
275288 // FEAT_RDM
276289 ( "rdm" , Stable , & [ "neon" ] ) ,
277- ( "reserve-x18" , Forbidden { reason : "use `-Zfixed-x18` compiler flag instead" } , & [ ] ) ,
290+ (
291+ "reserve-x18" ,
292+ Forbidden { reason : "use `-Zfixed-x18` compiler flag instead" , hard_error : false } ,
293+ & [ ] ,
294+ ) ,
278295 // FEAT_SB
279296 ( "sb" , Stable , & [ ] ) ,
280297 // FEAT_SHA1 & FEAT_SHA256
@@ -448,25 +465,38 @@ static X86_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
448465 ( "rdseed" , Stable , & [ ] ) ,
449466 (
450467 "retpoline-external-thunk" ,
451- Stability :: Forbidden { reason : "use `-Zretpoline-external-thunk` compiler flag instead" } ,
468+ Stability :: Forbidden {
469+ reason : "use `-Zretpoline-external-thunk` compiler flag instead" ,
470+ hard_error : false ,
471+ } ,
452472 & [ ] ,
453473 ) ,
454474 (
455475 "retpoline-indirect-branches" ,
456- Stability :: Forbidden { reason : "use `-Zretpoline` compiler flag instead" } ,
476+ Stability :: Forbidden {
477+ reason : "use `-Zretpoline` compiler flag instead" ,
478+ hard_error : false ,
479+ } ,
457480 & [ ] ,
458481 ) ,
459482 (
460483 "retpoline-indirect-calls" ,
461- Stability :: Forbidden { reason : "use `-Zretpoline` compiler flag instead" } ,
484+ Stability :: Forbidden {
485+ reason : "use `-Zretpoline` compiler flag instead" ,
486+ hard_error : false ,
487+ } ,
462488 & [ ] ,
463489 ) ,
464490 ( "rtm" , Unstable ( sym:: rtm_target_feature) , & [ ] ) ,
465491 ( "sha" , Stable , & [ "sse2" ] ) ,
466492 ( "sha512" , Stable , & [ "avx2" ] ) ,
467493 ( "sm3" , Stable , & [ "avx" ] ) ,
468494 ( "sm4" , Stable , & [ "avx2" ] ) ,
469- ( "soft-float" , Stability :: Forbidden { reason : "use a soft-float target instead" } , & [ ] ) ,
495+ (
496+ "soft-float" ,
497+ Stability :: Forbidden { reason : "use a soft-float target instead" , hard_error : false } ,
498+ & [ ] ,
499+ ) ,
470500 ( "sse" , Stable , & [ ] ) ,
471501 ( "sse2" , Stable , & [ "sse" ] ) ,
472502 ( "sse3" , Stable , & [ "sse2" ] ) ,
@@ -608,7 +638,10 @@ static RISCV_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
608638 ( "f" , Unstable ( sym:: riscv_target_feature) , & [ "zicsr" ] ) ,
609639 (
610640 "forced-atomics" ,
611- Stability :: Forbidden { reason : "unsound because it changes the ABI of atomic operations" } ,
641+ Stability :: Forbidden {
642+ reason : "unsound because it changes the ABI of atomic operations" ,
643+ hard_error : false ,
644+ } ,
612645 & [ ] ,
613646 ) ,
614647 ( "m" , Stable , & [ ] ) ,
@@ -863,7 +896,7 @@ const IBMZ_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
863896 ( "miscellaneous-extensions-3" , Stable , & [ ] ) ,
864897 ( "miscellaneous-extensions-4" , Stable , & [ ] ) ,
865898 ( "nnp-assist" , Stable , & [ "vector" ] ) ,
866- ( "soft-float" , Forbidden { reason : "unsupported ABI-configuration feature" } , & [ ] ) ,
899+ ( "soft-float" , Forbidden { reason : "unsupported ABI-configuration feature" , hard_error : false } , & [ ] ) ,
867900 ( "transactional-execution" , Unstable ( sym:: s390x_target_feature) , & [ ] ) ,
868901 ( "vector" , Stable , & [ ] ) ,
869902 ( "vector-enhancements-1" , Stable , & [ "vector" ] ) ,
@@ -915,7 +948,11 @@ static AVR_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
915948 ( "rmw" , Unstable ( sym:: avr_target_feature) , & [ ] ) ,
916949 ( "spm" , Unstable ( sym:: avr_target_feature) , & [ ] ) ,
917950 ( "spmx" , Unstable ( sym:: avr_target_feature) , & [ ] ) ,
918- ( "sram" , Forbidden { reason : "devices that have no SRAM are unsupported" } , & [ ] ) ,
951+ (
952+ "sram" ,
953+ Forbidden { reason : "devices that have no SRAM are unsupported" , hard_error : false } ,
954+ & [ ] ,
955+ ) ,
919956 ( "tinyencoding" , Unstable ( sym:: avr_target_feature) , & [ ] ) ,
920957 // tidy-alphabetical-end
921958] ;
0 commit comments