@@ -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
@@ -57,12 +62,12 @@ impl Stability {
5762 }
5863
5964 /// Returns whether the feature may be toggled via `#[target_feature]` or `-Ctarget-feature`.
60- /// (It might still be nightly-only even if this returns `true `, so make sure to also check
65+ /// (It might still be nightly-only even if this returns `Ok(()) `, so make sure to also check
6166 /// `requires_nightly`.)
6267 pub fn toggle_allowed ( & self ) -> Result < ( ) , & ' static str > {
6368 match self {
6469 Stability :: Unstable ( _) | Stability :: Stable { .. } => Ok ( ( ) ) ,
65- Stability :: Forbidden { reason } => Err ( reason) ,
70+ Stability :: Forbidden { reason, hard_error : _ } => Err ( reason) ,
6671 }
6772 }
6873}
@@ -119,7 +124,10 @@ static ARM_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
119124 ( "aes" , Unstable ( sym:: arm_target_feature) , & [ "neon" ] ) ,
120125 (
121126 "atomics-32" ,
122- Stability :: Forbidden { reason : "unsound because it changes the ABI of atomic operations" } ,
127+ Stability :: Forbidden {
128+ reason : "unsound because it changes the ABI of atomic operations" ,
129+ hard_error : false ,
130+ } ,
123131 & [ ] ,
124132 ) ,
125133 ( "crc" , Unstable ( sym:: arm_target_feature) , & [ ] ) ,
@@ -195,7 +203,11 @@ static AARCH64_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
195203 // FEAT_FLAGM2
196204 ( "flagm2" , Unstable ( sym:: aarch64_unstable_target_feature) , & [ ] ) ,
197205 // We forbid directly toggling just `fp-armv8`; it must be toggled with `neon`.
198- ( "fp-armv8" , Stability :: Forbidden { reason : "Rust ties `fp-armv8` to `neon`" } , & [ ] ) ,
206+ (
207+ "fp-armv8" ,
208+ Stability :: Forbidden { reason : "Rust ties `fp-armv8` to `neon`" , hard_error : false } ,
209+ & [ ] ,
210+ ) ,
199211 // FEAT_FP8
200212 ( "fp8" , Unstable ( sym:: aarch64_unstable_target_feature) , & [ "faminmax" , "lut" , "bf16" ] ) ,
201213 // FEAT_FP8DOT2
@@ -258,7 +270,11 @@ static AARCH64_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
258270 ( "rcpc3" , Unstable ( sym:: aarch64_unstable_target_feature) , & [ "rcpc2" ] ) ,
259271 // FEAT_RDM
260272 ( "rdm" , Stable , & [ "neon" ] ) ,
261- ( "reserve-x18" , Forbidden { reason : "use `-Zfixed-x18` compiler flag instead" } , & [ ] ) ,
273+ (
274+ "reserve-x18" ,
275+ Forbidden { reason : "use `-Zfixed-x18` compiler flag instead" , hard_error : false } ,
276+ & [ ] ,
277+ ) ,
262278 // FEAT_SB
263279 ( "sb" , Stable , & [ ] ) ,
264280 // FEAT_SHA1 & FEAT_SHA256
@@ -432,25 +448,38 @@ static X86_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
432448 ( "rdseed" , Stable , & [ ] ) ,
433449 (
434450 "retpoline-external-thunk" ,
435- Stability :: Forbidden { reason : "use `-Zretpoline-external-thunk` compiler flag instead" } ,
451+ Stability :: Forbidden {
452+ reason : "use `-Zretpoline-external-thunk` compiler flag instead" ,
453+ hard_error : false ,
454+ } ,
436455 & [ ] ,
437456 ) ,
438457 (
439458 "retpoline-indirect-branches" ,
440- Stability :: Forbidden { reason : "use `-Zretpoline` compiler flag instead" } ,
459+ Stability :: Forbidden {
460+ reason : "use `-Zretpoline` compiler flag instead" ,
461+ hard_error : false ,
462+ } ,
441463 & [ ] ,
442464 ) ,
443465 (
444466 "retpoline-indirect-calls" ,
445- Stability :: Forbidden { reason : "use `-Zretpoline` compiler flag instead" } ,
467+ Stability :: Forbidden {
468+ reason : "use `-Zretpoline` compiler flag instead" ,
469+ hard_error : false ,
470+ } ,
446471 & [ ] ,
447472 ) ,
448473 ( "rtm" , Unstable ( sym:: rtm_target_feature) , & [ ] ) ,
449474 ( "sha" , Stable , & [ "sse2" ] ) ,
450475 ( "sha512" , Stable , & [ "avx2" ] ) ,
451476 ( "sm3" , Stable , & [ "avx" ] ) ,
452477 ( "sm4" , Stable , & [ "avx2" ] ) ,
453- ( "soft-float" , Stability :: Forbidden { reason : "use a soft-float target instead" } , & [ ] ) ,
478+ (
479+ "soft-float" ,
480+ Stability :: Forbidden { reason : "use a soft-float target instead" , hard_error : false } ,
481+ & [ ] ,
482+ ) ,
454483 ( "sse" , Stable , & [ ] ) ,
455484 ( "sse2" , Stable , & [ "sse" ] ) ,
456485 ( "sse3" , Stable , & [ "sse2" ] ) ,
@@ -592,7 +621,10 @@ static RISCV_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
592621 ( "f" , Unstable ( sym:: riscv_target_feature) , & [ "zicsr" ] ) ,
593622 (
594623 "forced-atomics" ,
595- Stability :: Forbidden { reason : "unsound because it changes the ABI of atomic operations" } ,
624+ Stability :: Forbidden {
625+ reason : "unsound because it changes the ABI of atomic operations" ,
626+ hard_error : false ,
627+ } ,
596628 & [ ] ,
597629 ) ,
598630 ( "m" , Stable , & [ ] ) ,
@@ -847,7 +879,7 @@ const IBMZ_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
847879 ( "miscellaneous-extensions-3" , Stable , & [ ] ) ,
848880 ( "miscellaneous-extensions-4" , Stable , & [ ] ) ,
849881 ( "nnp-assist" , Stable , & [ "vector" ] ) ,
850- ( "soft-float" , Forbidden { reason : "unsupported ABI-configuration feature" } , & [ ] ) ,
882+ ( "soft-float" , Forbidden { reason : "unsupported ABI-configuration feature" , hard_error : false } , & [ ] ) ,
851883 ( "transactional-execution" , Unstable ( sym:: s390x_target_feature) , & [ ] ) ,
852884 ( "vector" , Stable , & [ ] ) ,
853885 ( "vector-enhancements-1" , Stable , & [ "vector" ] ) ,
@@ -899,7 +931,11 @@ static AVR_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
899931 ( "rmw" , Unstable ( sym:: avr_target_feature) , & [ ] ) ,
900932 ( "spm" , Unstable ( sym:: avr_target_feature) , & [ ] ) ,
901933 ( "spmx" , Unstable ( sym:: avr_target_feature) , & [ ] ) ,
902- ( "sram" , Forbidden { reason : "devices that have no SRAM are unsupported" } , & [ ] ) ,
934+ (
935+ "sram" ,
936+ Forbidden { reason : "devices that have no SRAM are unsupported" , hard_error : false } ,
937+ & [ ] ,
938+ ) ,
903939 ( "tinyencoding" , Unstable ( sym:: avr_target_feature) , & [ ] ) ,
904940 // tidy-alphabetical-end
905941] ;
0 commit comments