From 265a608daea277d5bdc666ed6598a9ff30b44d28 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 20 Aug 2026 09:34:38 +0200 Subject: [PATCH 1/3] Reapply "riscv: promote d, e, and f target_features to CfgStableToggleUnstable" This reverts commit 55c133a9912a1d2e77c3b5d057208926ca6c9c3f. --- compiler/rustc_target/src/target_features.rs | 6 ++--- ...le-target-feature-flag-enable.riscv.stderr | 2 +- ...d-target-feature-flag-disable.riscv.stderr | 2 +- ...unstable-target-feature-attribute-riscv.rs | 17 ++++++++++++++ ...able-target-feature-attribute-riscv.stderr | 23 +++++++++++++++++++ ...stable-target-feature-flag-enable-riscv.rs | 17 ++++++++++++++ ...le-target-feature-flag-enable-riscv.stderr | 10 ++++++++ 7 files changed, 72 insertions(+), 5 deletions(-) create mode 100644 tests/ui/target-feature/cfg-stable-toggle-unstable-target-feature-attribute-riscv.rs create mode 100644 tests/ui/target-feature/cfg-stable-toggle-unstable-target-feature-attribute-riscv.stderr create mode 100644 tests/ui/target-feature/cfg-stable-toggle-unstable-target-feature-flag-enable-riscv.rs create mode 100644 tests/ui/target-feature/cfg-stable-toggle-unstable-target-feature-flag-enable-riscv.stderr diff --git a/compiler/rustc_target/src/target_features.rs b/compiler/rustc_target/src/target_features.rs index 68ece92fbc9c0..c7e1a90effc66 100644 --- a/compiler/rustc_target/src/target_features.rs +++ b/compiler/rustc_target/src/target_features.rs @@ -680,9 +680,9 @@ static RISCV_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[ ("a", Stable, &["zaamo", "zalrsc"]), ("b", Stable, &["zba", "zbb", "zbs"]), ("c", Stable, &["zca"]), - ("d", Unstable(sym::riscv_target_feature), &["f"]), - ("e", Unstable(sym::riscv_target_feature), &[]), - ("f", Unstable(sym::riscv_target_feature), &["zicsr"]), + ("d", CfgStableToggleUnstable(sym::riscv_target_feature), &["f"]), + ("e", CfgStableToggleUnstable(sym::riscv_target_feature), &[]), + ("f", CfgStableToggleUnstable(sym::riscv_target_feature), &["zicsr"]), ( "forced-atomics", // Not implied by any CPU model or other feature. diff --git a/tests/ui/target-feature/abi-incompatible-target-feature-flag-enable.riscv.stderr b/tests/ui/target-feature/abi-incompatible-target-feature-flag-enable.riscv.stderr index 1995f9d993a63..cb17e7fad296d 100644 --- a/tests/ui/target-feature/abi-incompatible-target-feature-flag-enable.riscv.stderr +++ b/tests/ui/target-feature/abi-incompatible-target-feature-flag-enable.riscv.stderr @@ -1,6 +1,6 @@ warning: unstable feature specified for `-Ctarget-feature`: `d` | - = note: this feature is not stably supported; its behavior can change in the future + = note: this feature is allowed in cfg but unstable otherwise; its behavior can change in the future = note: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #162235 diff --git a/tests/ui/target-feature/abi-required-target-feature-flag-disable.riscv.stderr b/tests/ui/target-feature/abi-required-target-feature-flag-disable.riscv.stderr index c4ce26bfef8d3..a47e6dea6be57 100644 --- a/tests/ui/target-feature/abi-required-target-feature-flag-disable.riscv.stderr +++ b/tests/ui/target-feature/abi-required-target-feature-flag-disable.riscv.stderr @@ -1,6 +1,6 @@ warning: unstable feature specified for `-Ctarget-feature`: `d` | - = note: this feature is not stably supported; its behavior can change in the future + = note: this feature is allowed in cfg but unstable otherwise; its behavior can change in the future = note: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #162235 diff --git a/tests/ui/target-feature/cfg-stable-toggle-unstable-target-feature-attribute-riscv.rs b/tests/ui/target-feature/cfg-stable-toggle-unstable-target-feature-attribute-riscv.rs new file mode 100644 index 0000000000000..24d42e3df44d3 --- /dev/null +++ b/tests/ui/target-feature/cfg-stable-toggle-unstable-target-feature-attribute-riscv.rs @@ -0,0 +1,17 @@ +//! Ensure cfg-only stable target_features trigger errors when enabled via attribute. +//@ compile-flags: --crate-type=lib +//@ compile-flags: --target=riscv64gc-unknown-none-elf +//@ needs-llvm-components: riscv +//@ add-minicore +//@ ignore-backends: gcc +#![feature(no_core)] +#![no_core] + +extern crate minicore; +use minicore::*; + +#[target_feature(enable = "v")] +//~^ERROR: the target feature `v` is currently unstable +#[target_feature(enable = "f")] +//~^ERROR: the target feature `f` is allowed in cfg but unstable otherwise +pub unsafe fn my_fun() {} diff --git a/tests/ui/target-feature/cfg-stable-toggle-unstable-target-feature-attribute-riscv.stderr b/tests/ui/target-feature/cfg-stable-toggle-unstable-target-feature-attribute-riscv.stderr new file mode 100644 index 0000000000000..7f13c11798fcf --- /dev/null +++ b/tests/ui/target-feature/cfg-stable-toggle-unstable-target-feature-attribute-riscv.stderr @@ -0,0 +1,23 @@ +error[E0658]: the target feature `v` is currently unstable + --> $DIR/cfg-stable-toggle-unstable-target-feature-attribute-riscv.rs:13:18 + | +LL | #[target_feature(enable = "v")] + | ^^^^^^^^^^^^ + | + = note: see issue #150257 for more information + = help: add `#![feature(riscv_target_feature)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error[E0658]: the target feature `f` is allowed in cfg but unstable otherwise + --> $DIR/cfg-stable-toggle-unstable-target-feature-attribute-riscv.rs:15:18 + | +LL | #[target_feature(enable = "f")] + | ^^^^^^^^^^^^ + | + = note: see issue #150257 for more information + = help: add `#![feature(riscv_target_feature)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/target-feature/cfg-stable-toggle-unstable-target-feature-flag-enable-riscv.rs b/tests/ui/target-feature/cfg-stable-toggle-unstable-target-feature-flag-enable-riscv.rs new file mode 100644 index 0000000000000..ab2b75ed5190f --- /dev/null +++ b/tests/ui/target-feature/cfg-stable-toggle-unstable-target-feature-flag-enable-riscv.rs @@ -0,0 +1,17 @@ +//! Ensure cfg-only stable target_features trigger warnings when enabled via compile flag. +//@ check-pass +//@ compile-flags: --crate-type=lib +//@ compile-flags: --target=riscv64gc-unknown-none-elf -Ctarget-feature=+v -Ctarget-feature=+f +// FIXME(#147881): *disable* the feature again for minicore as otherwise that will fail to build. +//@ minicore-compile-flags: -Ctarget-feature=-v -Ctarget-feature=-f +//@ needs-llvm-components: riscv +//@ ignore-backends: gcc +//@ add-minicore +#![feature(no_core)] +#![no_core] + +extern crate minicore; +use minicore::*; + +//~? WARN unstable feature specified for `-Ctarget-feature` +//~? WARN unstable feature specified for `-Ctarget-feature` diff --git a/tests/ui/target-feature/cfg-stable-toggle-unstable-target-feature-flag-enable-riscv.stderr b/tests/ui/target-feature/cfg-stable-toggle-unstable-target-feature-flag-enable-riscv.stderr new file mode 100644 index 0000000000000..b0167221aabaa --- /dev/null +++ b/tests/ui/target-feature/cfg-stable-toggle-unstable-target-feature-flag-enable-riscv.stderr @@ -0,0 +1,10 @@ +warning: unstable feature specified for `-Ctarget-feature`: `v` + | + = note: this feature is not stably supported; its behavior can change in the future + +warning: unstable feature specified for `-Ctarget-feature`: `f` + | + = note: this feature is allowed in cfg but unstable otherwise; its behavior can change in the future + +warning: 2 warnings emitted + From 55c68a8af003e92e2559e4070b7b3f3a42f596c9 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 20 Aug 2026 09:56:30 +0200 Subject: [PATCH 2/3] do not stabilize 'e' --- compiler/rustc_target/src/target_features.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_target/src/target_features.rs b/compiler/rustc_target/src/target_features.rs index c7e1a90effc66..400f5c98ec0b7 100644 --- a/compiler/rustc_target/src/target_features.rs +++ b/compiler/rustc_target/src/target_features.rs @@ -681,7 +681,7 @@ static RISCV_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[ ("b", Stable, &["zba", "zbb", "zbs"]), ("c", Stable, &["zca"]), ("d", CfgStableToggleUnstable(sym::riscv_target_feature), &["f"]), - ("e", CfgStableToggleUnstable(sym::riscv_target_feature), &[]), + ("e", Unstable(sym::riscv_target_feature), &[]), // negative feature! needs special care. ("f", CfgStableToggleUnstable(sym::riscv_target_feature), &["zicsr"]), ( "forced-atomics", From dc66d145d7be6f9ad54cf9b42281a19923ddd98e Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 2 Sep 2026 21:07:36 +0200 Subject: [PATCH 3/3] fully stabilize d, f --- compiler/rustc_target/src/target_features.rs | 4 ++-- ...le-target-feature-flag-enable.riscv.stderr | 8 +------ ...incompatible-target-feature-flag-enable.rs | 1 - ...d-target-feature-flag-disable.riscv.stderr | 8 +------ ...bi-required-target-feature-flag-disable.rs | 2 +- ...unstable-target-feature-attribute-riscv.rs | 17 -------------- ...able-target-feature-attribute-riscv.stderr | 23 ------------------- ...stable-target-feature-flag-enable-riscv.rs | 17 -------------- ...le-target-feature-flag-enable-riscv.stderr | 10 -------- 9 files changed, 5 insertions(+), 85 deletions(-) delete mode 100644 tests/ui/target-feature/cfg-stable-toggle-unstable-target-feature-attribute-riscv.rs delete mode 100644 tests/ui/target-feature/cfg-stable-toggle-unstable-target-feature-attribute-riscv.stderr delete mode 100644 tests/ui/target-feature/cfg-stable-toggle-unstable-target-feature-flag-enable-riscv.rs delete mode 100644 tests/ui/target-feature/cfg-stable-toggle-unstable-target-feature-flag-enable-riscv.stderr diff --git a/compiler/rustc_target/src/target_features.rs b/compiler/rustc_target/src/target_features.rs index 400f5c98ec0b7..9826633d47033 100644 --- a/compiler/rustc_target/src/target_features.rs +++ b/compiler/rustc_target/src/target_features.rs @@ -680,9 +680,9 @@ static RISCV_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[ ("a", Stable, &["zaamo", "zalrsc"]), ("b", Stable, &["zba", "zbb", "zbs"]), ("c", Stable, &["zca"]), - ("d", CfgStableToggleUnstable(sym::riscv_target_feature), &["f"]), + ("d", Stable, &["f"]), ("e", Unstable(sym::riscv_target_feature), &[]), // negative feature! needs special care. - ("f", CfgStableToggleUnstable(sym::riscv_target_feature), &["zicsr"]), + ("f", Stable, &["zicsr"]), ( "forced-atomics", // Not implied by any CPU model or other feature. diff --git a/tests/ui/target-feature/abi-incompatible-target-feature-flag-enable.riscv.stderr b/tests/ui/target-feature/abi-incompatible-target-feature-flag-enable.riscv.stderr index cb17e7fad296d..bc40b139095a5 100644 --- a/tests/ui/target-feature/abi-incompatible-target-feature-flag-enable.riscv.stderr +++ b/tests/ui/target-feature/abi-incompatible-target-feature-flag-enable.riscv.stderr @@ -1,13 +1,7 @@ -warning: unstable feature specified for `-Ctarget-feature`: `d` - | - = note: this feature is allowed in cfg but unstable otherwise; its behavior can change in the future - = note: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #162235 - warning: target feature `d` must be disabled to ensure that the ABI of the current target can be implemented correctly | = note: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #162235 -warning: 2 warnings emitted +warning: 1 warning emitted diff --git a/tests/ui/target-feature/abi-incompatible-target-feature-flag-enable.rs b/tests/ui/target-feature/abi-incompatible-target-feature-flag-enable.rs index c6370f01c47d6..c6b5e15599d8e 100644 --- a/tests/ui/target-feature/abi-incompatible-target-feature-flag-enable.rs +++ b/tests/ui/target-feature/abi-incompatible-target-feature-flag-enable.rs @@ -19,5 +19,4 @@ extern crate minicore; use minicore::*; //~? WARN must be disabled to ensure that the ABI of the current target can be implemented correctly -//[riscv]~? WARN unstable feature specified for `-Ctarget-feature` //[x86]~? WARN use a soft-float target instead diff --git a/tests/ui/target-feature/abi-required-target-feature-flag-disable.riscv.stderr b/tests/ui/target-feature/abi-required-target-feature-flag-disable.riscv.stderr index a47e6dea6be57..e8a5e98793d10 100644 --- a/tests/ui/target-feature/abi-required-target-feature-flag-disable.riscv.stderr +++ b/tests/ui/target-feature/abi-required-target-feature-flag-disable.riscv.stderr @@ -1,13 +1,7 @@ -warning: unstable feature specified for `-Ctarget-feature`: `d` - | - = note: this feature is allowed in cfg but unstable otherwise; its behavior can change in the future - = note: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #162235 - warning: target feature `d` must be enabled to ensure that the ABI of the current target can be implemented correctly | = note: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #162235 -warning: 2 warnings emitted +warning: 1 warning emitted diff --git a/tests/ui/target-feature/abi-required-target-feature-flag-disable.rs b/tests/ui/target-feature/abi-required-target-feature-flag-disable.rs index 47b7abd50debb..4faef8d02d673 100644 --- a/tests/ui/target-feature/abi-required-target-feature-flag-disable.rs +++ b/tests/ui/target-feature/abi-required-target-feature-flag-disable.rs @@ -26,4 +26,4 @@ extern crate minicore; use minicore::*; //~? WARN must be enabled to ensure that the ABI of the current target can be implemented correctly -//[x86,riscv]~? WARN unstable feature specified for `-Ctarget-feature` +//[x86]~? WARN unstable feature specified for `-Ctarget-feature` diff --git a/tests/ui/target-feature/cfg-stable-toggle-unstable-target-feature-attribute-riscv.rs b/tests/ui/target-feature/cfg-stable-toggle-unstable-target-feature-attribute-riscv.rs deleted file mode 100644 index 24d42e3df44d3..0000000000000 --- a/tests/ui/target-feature/cfg-stable-toggle-unstable-target-feature-attribute-riscv.rs +++ /dev/null @@ -1,17 +0,0 @@ -//! Ensure cfg-only stable target_features trigger errors when enabled via attribute. -//@ compile-flags: --crate-type=lib -//@ compile-flags: --target=riscv64gc-unknown-none-elf -//@ needs-llvm-components: riscv -//@ add-minicore -//@ ignore-backends: gcc -#![feature(no_core)] -#![no_core] - -extern crate minicore; -use minicore::*; - -#[target_feature(enable = "v")] -//~^ERROR: the target feature `v` is currently unstable -#[target_feature(enable = "f")] -//~^ERROR: the target feature `f` is allowed in cfg but unstable otherwise -pub unsafe fn my_fun() {} diff --git a/tests/ui/target-feature/cfg-stable-toggle-unstable-target-feature-attribute-riscv.stderr b/tests/ui/target-feature/cfg-stable-toggle-unstable-target-feature-attribute-riscv.stderr deleted file mode 100644 index 7f13c11798fcf..0000000000000 --- a/tests/ui/target-feature/cfg-stable-toggle-unstable-target-feature-attribute-riscv.stderr +++ /dev/null @@ -1,23 +0,0 @@ -error[E0658]: the target feature `v` is currently unstable - --> $DIR/cfg-stable-toggle-unstable-target-feature-attribute-riscv.rs:13:18 - | -LL | #[target_feature(enable = "v")] - | ^^^^^^^^^^^^ - | - = note: see issue #150257 for more information - = help: add `#![feature(riscv_target_feature)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0658]: the target feature `f` is allowed in cfg but unstable otherwise - --> $DIR/cfg-stable-toggle-unstable-target-feature-attribute-riscv.rs:15:18 - | -LL | #[target_feature(enable = "f")] - | ^^^^^^^^^^^^ - | - = note: see issue #150257 for more information - = help: add `#![feature(riscv_target_feature)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/target-feature/cfg-stable-toggle-unstable-target-feature-flag-enable-riscv.rs b/tests/ui/target-feature/cfg-stable-toggle-unstable-target-feature-flag-enable-riscv.rs deleted file mode 100644 index ab2b75ed5190f..0000000000000 --- a/tests/ui/target-feature/cfg-stable-toggle-unstable-target-feature-flag-enable-riscv.rs +++ /dev/null @@ -1,17 +0,0 @@ -//! Ensure cfg-only stable target_features trigger warnings when enabled via compile flag. -//@ check-pass -//@ compile-flags: --crate-type=lib -//@ compile-flags: --target=riscv64gc-unknown-none-elf -Ctarget-feature=+v -Ctarget-feature=+f -// FIXME(#147881): *disable* the feature again for minicore as otherwise that will fail to build. -//@ minicore-compile-flags: -Ctarget-feature=-v -Ctarget-feature=-f -//@ needs-llvm-components: riscv -//@ ignore-backends: gcc -//@ add-minicore -#![feature(no_core)] -#![no_core] - -extern crate minicore; -use minicore::*; - -//~? WARN unstable feature specified for `-Ctarget-feature` -//~? WARN unstable feature specified for `-Ctarget-feature` diff --git a/tests/ui/target-feature/cfg-stable-toggle-unstable-target-feature-flag-enable-riscv.stderr b/tests/ui/target-feature/cfg-stable-toggle-unstable-target-feature-flag-enable-riscv.stderr deleted file mode 100644 index b0167221aabaa..0000000000000 --- a/tests/ui/target-feature/cfg-stable-toggle-unstable-target-feature-flag-enable-riscv.stderr +++ /dev/null @@ -1,10 +0,0 @@ -warning: unstable feature specified for `-Ctarget-feature`: `v` - | - = note: this feature is not stably supported; its behavior can change in the future - -warning: unstable feature specified for `-Ctarget-feature`: `f` - | - = note: this feature is allowed in cfg but unstable otherwise; its behavior can change in the future - -warning: 2 warnings emitted -