From 04d262559ec81d3223bbc167dc704da33495ffcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Fri, 23 Oct 2026 15:38:15 +0200 Subject: [PATCH 1/5] Migrate the `missing-unstable-trait-bound` test from a run-make test to a UI test --- .../missing-bound.rs | 4 --- .../missing-bound.stderr | 13 ---------- .../missing-unstable-trait-bound/rmake.rs | 25 ------------------- ...issing-unstable-trait-bound.nightly.stderr | 17 +++++++++++++ .../missing-unstable-trait-bound.rs | 16 ++++++++++++ ...missing-unstable-trait-bound.stable.stderr | 13 ++++++++++ 6 files changed, 46 insertions(+), 42 deletions(-) delete mode 100644 tests/run-make/missing-unstable-trait-bound/missing-bound.rs delete mode 100644 tests/run-make/missing-unstable-trait-bound/missing-bound.stderr delete mode 100644 tests/run-make/missing-unstable-trait-bound/rmake.rs create mode 100644 tests/ui/trait-bounds/missing-unstable-trait-bound.nightly.stderr create mode 100644 tests/ui/trait-bounds/missing-unstable-trait-bound.rs create mode 100644 tests/ui/trait-bounds/missing-unstable-trait-bound.stable.stderr diff --git a/tests/run-make/missing-unstable-trait-bound/missing-bound.rs b/tests/run-make/missing-unstable-trait-bound/missing-bound.rs deleted file mode 100644 index 65d0745f49440..0000000000000 --- a/tests/run-make/missing-unstable-trait-bound/missing-bound.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub fn baz(t: std::ops::Range) { - for _ in t {} -} -fn main() {} diff --git a/tests/run-make/missing-unstable-trait-bound/missing-bound.stderr b/tests/run-make/missing-unstable-trait-bound/missing-bound.stderr deleted file mode 100644 index d680ae1aca1d3..0000000000000 --- a/tests/run-make/missing-unstable-trait-bound/missing-bound.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0277]: `std::ops::Range` is not an iterator - --> missing-bound.rs:2:14 - | -2 | for _ in t {} - | ^ `Range` is not an iterator - | - = note: `Range` only implements `Iterator` for select types in the standard library, particularly integers; to see the full list of types, see the documentation for the unstable `Step` trait - = note: required for `std::ops::Range` to implement `Iterator` - = note: required for `std::ops::Range` to implement `IntoIterator` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/run-make/missing-unstable-trait-bound/rmake.rs b/tests/run-make/missing-unstable-trait-bound/rmake.rs deleted file mode 100644 index 807d24b630fd6..0000000000000 --- a/tests/run-make/missing-unstable-trait-bound/rmake.rs +++ /dev/null @@ -1,25 +0,0 @@ -//@ only-linux -//@ ignore-wasm32 -//@ ignore-wasm64 -// ignore-tidy-linelength -//@ ignore-backends: gcc - -// Ensure that on stable we don't suggest restricting with an unsafe trait and we continue -// mentioning the rest of the obligation chain. - -use run_make_support::{diff, stable_bare_rustc}; - -fn main() { - let out = stable_bare_rustc() - .edition("2015") - .input("missing-bound.rs") - .run_fail() - .assert_stderr_not_contains("help: consider restricting type parameter `T`") - .assert_stderr_contains( - r#" - = note: required for `std::ops::Range` to implement `Iterator` - = note: required for `std::ops::Range` to implement `IntoIterator`"#, - ) - .stderr_utf8(); - diff().expected_file("missing-bound.stderr").actual_text("(stable rustc)", &out).run() -} diff --git a/tests/ui/trait-bounds/missing-unstable-trait-bound.nightly.stderr b/tests/ui/trait-bounds/missing-unstable-trait-bound.nightly.stderr new file mode 100644 index 0000000000000..75381e75bf558 --- /dev/null +++ b/tests/ui/trait-bounds/missing-unstable-trait-bound.nightly.stderr @@ -0,0 +1,17 @@ +error[E0277]: `std::ops::Range` is not an iterator + --> $DIR/missing-unstable-trait-bound.rs:13:14 + | +LL | for _ in t {} + | ^ `Range` is not an iterator + | + = note: `Range` only implements `Iterator` for select types in the standard library, particularly integers; to see the full list of types, see the documentation for the unstable `Step` trait + = note: required for `std::ops::Range` to implement `Iterator` + = note: required for `std::ops::Range` to implement `IntoIterator` +help: consider restricting type parameter `T` with unstable trait `Step` + | +LL | pub fn baz(t: std::ops::Range) { + | +++++++++++++++++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/trait-bounds/missing-unstable-trait-bound.rs b/tests/ui/trait-bounds/missing-unstable-trait-bound.rs new file mode 100644 index 0000000000000..ab77ffce3d768 --- /dev/null +++ b/tests/ui/trait-bounds/missing-unstable-trait-bound.rs @@ -0,0 +1,16 @@ +//! Ensure that on stable we don't suggest restricting with an unsafe trait, and we continue +//! mentioning the rest of the obligation chain. + +//@ ignore-wasm32 +//@ ignore-wasm64 +//@ ignore-backends: gcc +// +//@ revisions: stable nightly +//@[stable] act-as-stable +//@[nightly] only-nightly + +pub fn baz(t: std::ops::Range) { + for _ in t {} + //~^ ERROR: `std::ops::Range` is not an iterator [E0277] +} +fn main() {} diff --git a/tests/ui/trait-bounds/missing-unstable-trait-bound.stable.stderr b/tests/ui/trait-bounds/missing-unstable-trait-bound.stable.stderr new file mode 100644 index 0000000000000..f647267ac2e07 --- /dev/null +++ b/tests/ui/trait-bounds/missing-unstable-trait-bound.stable.stderr @@ -0,0 +1,13 @@ +error[E0277]: `std::ops::Range` is not an iterator + --> $DIR/missing-unstable-trait-bound.rs:13:14 + | +LL | for _ in t {} + | ^ `Range` is not an iterator + | + = note: `Range` only implements `Iterator` for select types in the standard library, particularly integers; to see the full list of types, see the documentation for the unstable `Step` trait + = note: required for `std::ops::Range` to implement `Iterator` + = note: required for `std::ops::Range` to implement `IntoIterator` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. From 2cb98f835b93321761badcca0d8daeae1682a4b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Fri, 23 Oct 2026 16:11:55 +0200 Subject: [PATCH 2/5] Migrate the `const-trait-stable-toolchain` test from a run-make test to a UI test --- .../const-super-trait-nightly-enabled.stderr | 56 --------- .../const-super-trait-stable-disabled.stderr | 72 ------------ .../const-super-trait-stable-enabled.stderr | 62 ---------- .../const-super-trait.rs | 13 -- .../const-trait-stable-toolchain/rmake.rs | 60 ---------- ...supertrait-unstable.nightly-enabled.stderr | 92 +++++++++++++++ .../const-supertrait-unstable.nightly.stderr} | 54 +++++++-- .../const-traits/const-supertrait-unstable.rs | 38 ++++++ ...-supertrait-unstable.stable-enabled.stderr | 101 ++++++++++++++++ .../const-supertrait-unstable.stable.stderr | 111 ++++++++++++++++++ 10 files changed, 387 insertions(+), 272 deletions(-) delete mode 100644 tests/run-make/const-trait-stable-toolchain/const-super-trait-nightly-enabled.stderr delete mode 100644 tests/run-make/const-trait-stable-toolchain/const-super-trait-stable-disabled.stderr delete mode 100644 tests/run-make/const-trait-stable-toolchain/const-super-trait-stable-enabled.stderr delete mode 100644 tests/run-make/const-trait-stable-toolchain/const-super-trait.rs delete mode 100644 tests/run-make/const-trait-stable-toolchain/rmake.rs create mode 100644 tests/ui/traits/const-traits/const-supertrait-unstable.nightly-enabled.stderr rename tests/{run-make/const-trait-stable-toolchain/const-super-trait-nightly-disabled.stderr => ui/traits/const-traits/const-supertrait-unstable.nightly.stderr} (57%) create mode 100644 tests/ui/traits/const-traits/const-supertrait-unstable.rs create mode 100644 tests/ui/traits/const-traits/const-supertrait-unstable.stable-enabled.stderr create mode 100644 tests/ui/traits/const-traits/const-supertrait-unstable.stable.stderr diff --git a/tests/run-make/const-trait-stable-toolchain/const-super-trait-nightly-enabled.stderr b/tests/run-make/const-trait-stable-toolchain/const-super-trait-nightly-enabled.stderr deleted file mode 100644 index c1b35e733a1ff..0000000000000 --- a/tests/run-make/const-trait-stable-toolchain/const-super-trait-nightly-enabled.stderr +++ /dev/null @@ -1,56 +0,0 @@ -error: `[const]` is not allowed here - --> const-super-trait.rs:7:12 - | -LL | trait Bar: [const] Foo {} - | ^^^^^^^ - | -note: this trait is not `const`, so it cannot have `[const]` trait bounds - --> const-super-trait.rs:7:1 - | -LL | trait Bar: [const] Foo {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: `[const]` can only be applied to `const` traits - --> const-super-trait.rs:7:12 - | -LL | trait Bar: [const] Foo {} - | ^^^^^^^ can't be applied to `Foo` - | -help: mark `Foo` as `const` to allow it to have `const` implementations - | -LL | const trait Foo { - | +++++ - -error: `[const]` can only be applied to `const` traits - --> const-super-trait.rs:9:17 - | -LL | const fn foo(x: &T) { - | ^^^^^^^ can't be applied to `Bar` - | -help: mark `Bar` as `const` to allow it to have `const` implementations - | -LL | const trait Bar: [const] Foo {} - | +++++ - -error[E0015]: cannot call non-const method `::a` in constant functions - --> const-super-trait.rs:10:7 - | -LL | x.a(); - | ^^^ - | -note: method `a` is not const because trait `Foo` is not const - --> const-super-trait.rs:3:1 - | -LL | trait Foo { - | ^^^^^^^^^ this trait is not const -LL | fn a(&self); - | ------------ this method is not const - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants -help: consider making trait `Foo` const - | -LL | const trait Foo { - | +++++ - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0015`. diff --git a/tests/run-make/const-trait-stable-toolchain/const-super-trait-stable-disabled.stderr b/tests/run-make/const-trait-stable-toolchain/const-super-trait-stable-disabled.stderr deleted file mode 100644 index e8b5c09699202..0000000000000 --- a/tests/run-make/const-trait-stable-toolchain/const-super-trait-stable-disabled.stderr +++ /dev/null @@ -1,72 +0,0 @@ -error: `[const]` is not allowed here - --> const-super-trait.rs:7:12 - | -7 | trait Bar: [const] Foo {} - | ^^^^^^^ - | -note: this trait is not `const`, so it cannot have `[const]` trait bounds - --> const-super-trait.rs:7:1 - | -7 | trait Bar: [const] Foo {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0658]: const trait impls are experimental - --> const-super-trait.rs:7:12 - | -7 | trait Bar: [const] Foo {} - | ^^^^^^^ - | - = note: see issue #143874 for more information - -error[E0658]: const trait impls are experimental - --> const-super-trait.rs:9:17 - | -9 | const fn foo(x: &T) { - | ^^^^^^^ - | - = note: see issue #143874 for more information - -error: `[const]` can only be applied to `const` traits - --> const-super-trait.rs:7:12 - | -7 | trait Bar: [const] Foo {} - | ^^^^^^^ can't be applied to `Foo` - | -note: `Foo` can't be used with `[const]` because it isn't `const` - --> const-super-trait.rs:3:1 - | -3 | trait Foo { - | ^^^^^^^^^ - -error: `[const]` can only be applied to `const` traits - --> const-super-trait.rs:9:17 - | -9 | const fn foo(x: &T) { - | ^^^^^^^ can't be applied to `Bar` - | -note: `Bar` can't be used with `[const]` because it isn't `const` - --> const-super-trait.rs:7:1 - | -7 | trait Bar: [const] Foo {} - | ^^^^^^^^^^^^^^^^^^^^^^ - -error[E0015]: cannot call non-const method `::a` in constant functions - --> const-super-trait.rs:10:7 - | -10 | x.a(); - | ^^^ - | -note: method `a` is not const because trait `Foo` is not const - --> const-super-trait.rs:3:1 - | - 3 | trait Foo { - | ^^^^^^^^^ this trait is not const - 4 | fn a(&self); - | ------------ this method is not const - = help: const traits are not yet supported on stable Rust - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants - -error: aborting due to 6 previous errors - -Some errors have detailed explanations: E0015, E0658. -For more information about an error, try `rustc --explain E0015`. diff --git a/tests/run-make/const-trait-stable-toolchain/const-super-trait-stable-enabled.stderr b/tests/run-make/const-trait-stable-toolchain/const-super-trait-stable-enabled.stderr deleted file mode 100644 index 263532f3a9400..0000000000000 --- a/tests/run-make/const-trait-stable-toolchain/const-super-trait-stable-enabled.stderr +++ /dev/null @@ -1,62 +0,0 @@ -error: `[const]` is not allowed here - --> const-super-trait.rs:7:12 - | -7 | trait Bar: [const] Foo {} - | ^^^^^^^ - | -note: this trait is not `const`, so it cannot have `[const]` trait bounds - --> const-super-trait.rs:7:1 - | -7 | trait Bar: [const] Foo {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0554]: `#![feature]` may not be used on the NIGHTLY release channel - --> const-super-trait.rs:1:30 - | -1 | #![cfg_attr(feature_enabled, feature(const_trait_impl))] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: `[const]` can only be applied to `const` traits - --> const-super-trait.rs:7:12 - | -7 | trait Bar: [const] Foo {} - | ^^^^^^^ can't be applied to `Foo` - | -note: `Foo` can't be used with `[const]` because it isn't `const` - --> const-super-trait.rs:3:1 - | -3 | trait Foo { - | ^^^^^^^^^ - -error: `[const]` can only be applied to `const` traits - --> const-super-trait.rs:9:17 - | -9 | const fn foo(x: &T) { - | ^^^^^^^ can't be applied to `Bar` - | -note: `Bar` can't be used with `[const]` because it isn't `const` - --> const-super-trait.rs:7:1 - | -7 | trait Bar: [const] Foo {} - | ^^^^^^^^^^^^^^^^^^^^^^ - -error[E0015]: cannot call non-const method `::a` in constant functions - --> const-super-trait.rs:10:7 - | -10 | x.a(); - | ^^^ - | -note: method `a` is not const because trait `Foo` is not const - --> const-super-trait.rs:3:1 - | - 3 | trait Foo { - | ^^^^^^^^^ this trait is not const - 4 | fn a(&self); - | ------------ this method is not const - = help: const traits are not yet supported on stable Rust - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants - -error: aborting due to 5 previous errors - -Some errors have detailed explanations: E0015, E0554. -For more information about an error, try `rustc --explain E0015`. diff --git a/tests/run-make/const-trait-stable-toolchain/const-super-trait.rs b/tests/run-make/const-trait-stable-toolchain/const-super-trait.rs deleted file mode 100644 index 2371dfc0e6d08..0000000000000 --- a/tests/run-make/const-trait-stable-toolchain/const-super-trait.rs +++ /dev/null @@ -1,13 +0,0 @@ -#![cfg_attr(feature_enabled, feature(const_trait_impl))] - -trait Foo { - fn a(&self); -} - -trait Bar: [const] Foo {} - -const fn foo(x: &T) { - x.a(); -} - -fn main() {} diff --git a/tests/run-make/const-trait-stable-toolchain/rmake.rs b/tests/run-make/const-trait-stable-toolchain/rmake.rs deleted file mode 100644 index a13b1cb936bbb..0000000000000 --- a/tests/run-make/const-trait-stable-toolchain/rmake.rs +++ /dev/null @@ -1,60 +0,0 @@ -//@ needs-target-std -//@ ignore-backends: gcc - -// Test output of const super trait errors in both stable and nightly. -// We don't want to provide suggestions on stable that only make sense in nightly. - -use run_make_support::{diff, rustc, stable_bare_rustc}; - -fn main() { - let out = stable_bare_rustc() - .edition("2015") - .input("const-super-trait.rs") - .cfg("feature_enabled") - .run_fail() - .assert_stderr_not_contains("as `const` to allow it to have `const` implementations") - .stderr_utf8(); - diff() - .expected_file("const-super-trait-stable-enabled.stderr") - .normalize( - "may not be used on the .* release channel", - "may not be used on the NIGHTLY release channel", - ) - .actual_text("(rustc)", &out) - .run(); - let out = rustc() - .edition("2015") - .input("const-super-trait.rs") - .cfg("feature_enabled") - .ui_testing() - .run_fail() - .assert_stderr_not_contains("enable `#![feature(const_trait_impl)]` in your crate and mark") - .assert_stderr_contains("as `const` to allow it to have `const` implementations") - .stderr_utf8(); - diff() - .expected_file("const-super-trait-nightly-enabled.stderr") - .actual_text("(rustc)", &out) - .run(); - let out = stable_bare_rustc() - .edition("2015") - .input("const-super-trait.rs") - .run_fail() - .assert_stderr_not_contains("enable `#![feature(const_trait_impl)]` in your crate and mark") - .assert_stderr_not_contains("as `const` to allow it to have `const` implementations") - .stderr_utf8(); - diff() - .expected_file("const-super-trait-stable-disabled.stderr") - .actual_text("(rustc)", &out) - .run(); - let out = rustc() - .edition("2015") - .input("const-super-trait.rs") - .ui_testing() - .run_fail() - .assert_stderr_contains("enable `#![feature(const_trait_impl)]` in your crate and mark") - .stderr_utf8(); - diff() - .expected_file("const-super-trait-nightly-disabled.stderr") - .actual_text("(rustc)", &out) - .run(); -} diff --git a/tests/ui/traits/const-traits/const-supertrait-unstable.nightly-enabled.stderr b/tests/ui/traits/const-traits/const-supertrait-unstable.nightly-enabled.stderr new file mode 100644 index 0000000000000..43ac8df50d8f1 --- /dev/null +++ b/tests/ui/traits/const-traits/const-supertrait-unstable.nightly-enabled.stderr @@ -0,0 +1,92 @@ +error: `[const]` is not allowed here + --> $DIR/const-supertrait-unstable.rs:25:12 + | +LL | trait Bar: [const] Foo {} + | ^^^^^^^ + | +note: this trait is not `const`, so it cannot have `[const]` trait bounds + --> $DIR/const-supertrait-unstable.rs:25:1 + | +LL | trait Bar: [const] Foo {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `[const]` can only be applied to `const` traits + --> $DIR/const-supertrait-unstable.rs:25:12 + | +LL | trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` + | +help: mark `Foo` as `const` to allow it to have `const` implementations + | +LL | const trait Foo { + | +++++ + +error: `[const]` can only be applied to `const` traits + --> $DIR/const-supertrait-unstable.rs:25:12 + | +LL | trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +help: mark `Foo` as `const` to allow it to have `const` implementations + | +LL | const trait Foo { + | +++++ + +error: `[const]` can only be applied to `const` traits + --> $DIR/const-supertrait-unstable.rs:25:12 + | +LL | trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +help: mark `Foo` as `const` to allow it to have `const` implementations + | +LL | const trait Foo { + | +++++ + +error: `[const]` can only be applied to `const` traits + --> $DIR/const-supertrait-unstable.rs:32:17 + | +LL | const fn foo(x: &T) { + | ^^^^^^^ can't be applied to `Bar` + | +help: mark `Bar` as `const` to allow it to have `const` implementations + | +LL | const trait Bar: [const] Foo {} + | +++++ + +error: `[const]` can only be applied to `const` traits + --> $DIR/const-supertrait-unstable.rs:32:17 + | +LL | const fn foo(x: &T) { + | ^^^^^^^ can't be applied to `Bar` + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +help: mark `Bar` as `const` to allow it to have `const` implementations + | +LL | const trait Bar: [const] Foo {} + | +++++ + +error[E0015]: cannot call non-const method `::a` in constant functions + --> $DIR/const-supertrait-unstable.rs:36:7 + | +LL | x.a(); + | ^^^ + | +note: method `a` is not const because trait `Foo` is not const + --> $DIR/const-supertrait-unstable.rs:21:1 + | +LL | trait Foo { + | ^^^^^^^^^ this trait is not const +LL | fn a(&self); + | ------------ this method is not const + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants +help: consider making trait `Foo` const + | +LL | const trait Foo { + | +++++ + +error: aborting due to 7 previous errors + +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/run-make/const-trait-stable-toolchain/const-super-trait-nightly-disabled.stderr b/tests/ui/traits/const-traits/const-supertrait-unstable.nightly.stderr similarity index 57% rename from tests/run-make/const-trait-stable-toolchain/const-super-trait-nightly-disabled.stderr rename to tests/ui/traits/const-traits/const-supertrait-unstable.nightly.stderr index 46b0ce96b1fee..ed1fa6bf261a9 100644 --- a/tests/run-make/const-trait-stable-toolchain/const-super-trait-nightly-disabled.stderr +++ b/tests/ui/traits/const-traits/const-supertrait-unstable.nightly.stderr @@ -1,17 +1,17 @@ error: `[const]` is not allowed here - --> const-super-trait.rs:7:12 + --> $DIR/const-supertrait-unstable.rs:25:12 | LL | trait Bar: [const] Foo {} | ^^^^^^^ | note: this trait is not `const`, so it cannot have `[const]` trait bounds - --> const-super-trait.rs:7:1 + --> $DIR/const-supertrait-unstable.rs:25:1 | LL | trait Bar: [const] Foo {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0658]: const trait impls are experimental - --> const-super-trait.rs:7:12 + --> $DIR/const-supertrait-unstable.rs:25:12 | LL | trait Bar: [const] Foo {} | ^^^^^^^ @@ -21,7 +21,7 @@ LL | trait Bar: [const] Foo {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: const trait impls are experimental - --> const-super-trait.rs:9:17 + --> $DIR/const-supertrait-unstable.rs:32:17 | LL | const fn foo(x: &T) { | ^^^^^^^ @@ -31,7 +31,7 @@ LL | const fn foo(x: &T) { = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error: `[const]` can only be applied to `const` traits - --> const-super-trait.rs:7:12 + --> $DIR/const-supertrait-unstable.rs:25:12 | LL | trait Bar: [const] Foo {} | ^^^^^^^ can't be applied to `Foo` @@ -42,24 +42,60 @@ LL | const trait Foo { | +++++ error: `[const]` can only be applied to `const` traits - --> const-super-trait.rs:9:17 + --> $DIR/const-supertrait-unstable.rs:25:12 + | +LL | trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `const` to allow it to have `const` implementations + | +LL | const trait Foo { + | +++++ + +error: `[const]` can only be applied to `const` traits + --> $DIR/const-supertrait-unstable.rs:25:12 + | +LL | trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `const` to allow it to have `const` implementations + | +LL | const trait Foo { + | +++++ + +error: `[const]` can only be applied to `const` traits + --> $DIR/const-supertrait-unstable.rs:32:17 + | +LL | const fn foo(x: &T) { + | ^^^^^^^ can't be applied to `Bar` + | +help: enable `#![feature(const_trait_impl)]` in your crate and mark `Bar` as `const` to allow it to have `const` implementations + | +LL | const trait Bar: [const] Foo {} + | +++++ + +error: `[const]` can only be applied to `const` traits + --> $DIR/const-supertrait-unstable.rs:32:17 | LL | const fn foo(x: &T) { | ^^^^^^^ can't be applied to `Bar` | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: enable `#![feature(const_trait_impl)]` in your crate and mark `Bar` as `const` to allow it to have `const` implementations | LL | const trait Bar: [const] Foo {} | +++++ error[E0015]: cannot call non-const method `::a` in constant functions - --> const-super-trait.rs:10:7 + --> $DIR/const-supertrait-unstable.rs:36:7 | LL | x.a(); | ^^^ | note: method `a` is not const because trait `Foo` is not const - --> const-super-trait.rs:3:1 + --> $DIR/const-supertrait-unstable.rs:21:1 | LL | trait Foo { | ^^^^^^^^^ this trait is not const @@ -72,7 +108,7 @@ help: consider making trait `Foo` const LL | const trait Foo { | +++++ -error: aborting due to 6 previous errors +error: aborting due to 9 previous errors Some errors have detailed explanations: E0015, E0658. For more information about an error, try `rustc --explain E0015`. diff --git a/tests/ui/traits/const-traits/const-supertrait-unstable.rs b/tests/ui/traits/const-traits/const-supertrait-unstable.rs new file mode 100644 index 0000000000000..246124b570602 --- /dev/null +++ b/tests/ui/traits/const-traits/const-supertrait-unstable.rs @@ -0,0 +1,38 @@ +//! Test output of const super trait errors in both stable and nightly. +//! We don't want to provide suggestions on stable that only make sense in nightly. + +//@ needs-target-std +//@ ignore-backends: gcc + +//@ compile-flags: --check-cfg=cfg(feature_enabled) +//@ revisions: stable stable-enabled nightly nightly-enabled +//@[stable] act-as-stable +//@[stable-enabled] act-as-stable +//@[stable-enabled] compile-flags: --cfg feature_enabled +//@[nightly] only-nightly +//@[nightly-enabled] only-nightly +//@[nightly-enabled] compile-flags: --cfg feature_enabled + +#![cfg_attr(feature_enabled, feature(const_trait_impl))] +//[stable-enabled]~^ ERROR: `#![feature]` may not be used + +trait Foo { + fn a(&self); +} + +trait Bar: [const] Foo {} +//~^ ERROR: `[const]` is not allowed here +//[nightly,stable]~^^ ERROR: const trait impls are experimental [E0658] +//~| ERROR: `[const]` can only be applied to `const` traits +//~| ERROR: `[const]` can only be applied to `const` traits +//~| ERROR: `[const]` can only be applied to `const` traits + +const fn foo(x: &T) { + //[nightly,stable]~^ ERROR: const trait impls are experimental [E0658] + //~^^ ERROR: `[const]` can only be applied to `const` traits + //~| ERROR: `[const]` can only be applied to `const` traits + x.a(); + //~^ ERROR: cannot call non-const method `::a` in constant functions [E0015] +} + +fn main() {} diff --git a/tests/ui/traits/const-traits/const-supertrait-unstable.stable-enabled.stderr b/tests/ui/traits/const-traits/const-supertrait-unstable.stable-enabled.stderr new file mode 100644 index 0000000000000..dbcc8d46d3fc7 --- /dev/null +++ b/tests/ui/traits/const-traits/const-supertrait-unstable.stable-enabled.stderr @@ -0,0 +1,101 @@ +error: `[const]` is not allowed here + --> $DIR/const-supertrait-unstable.rs:25:12 + | +LL | trait Bar: [const] Foo {} + | ^^^^^^^ + | +note: this trait is not `const`, so it cannot have `[const]` trait bounds + --> $DIR/const-supertrait-unstable.rs:25:1 + | +LL | trait Bar: [const] Foo {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0554]: `#![feature]` may not be used on the nightly release channel + --> $DIR/const-supertrait-unstable.rs:18:30 + | +LL | #![cfg_attr(feature_enabled, feature(const_trait_impl))] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `[const]` can only be applied to `const` traits + --> $DIR/const-supertrait-unstable.rs:25:12 + | +LL | trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` + | +note: `Foo` can't be used with `[const]` because it isn't `const` + --> $DIR/const-supertrait-unstable.rs:21:1 + | +LL | trait Foo { + | ^^^^^^^^^ + +error: `[const]` can only be applied to `const` traits + --> $DIR/const-supertrait-unstable.rs:25:12 + | +LL | trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` + | +note: `Foo` can't be used with `[const]` because it isn't `const` + --> $DIR/const-supertrait-unstable.rs:21:1 + | +LL | trait Foo { + | ^^^^^^^^^ + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: `[const]` can only be applied to `const` traits + --> $DIR/const-supertrait-unstable.rs:25:12 + | +LL | trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` + | +note: `Foo` can't be used with `[const]` because it isn't `const` + --> $DIR/const-supertrait-unstable.rs:21:1 + | +LL | trait Foo { + | ^^^^^^^^^ + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: `[const]` can only be applied to `const` traits + --> $DIR/const-supertrait-unstable.rs:32:17 + | +LL | const fn foo(x: &T) { + | ^^^^^^^ can't be applied to `Bar` + | +note: `Bar` can't be used with `[const]` because it isn't `const` + --> $DIR/const-supertrait-unstable.rs:25:1 + | +LL | trait Bar: [const] Foo {} + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: `[const]` can only be applied to `const` traits + --> $DIR/const-supertrait-unstable.rs:32:17 + | +LL | const fn foo(x: &T) { + | ^^^^^^^ can't be applied to `Bar` + | +note: `Bar` can't be used with `[const]` because it isn't `const` + --> $DIR/const-supertrait-unstable.rs:25:1 + | +LL | trait Bar: [const] Foo {} + | ^^^^^^^^^^^^^^^^^^^^^^ + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error[E0015]: cannot call non-const method `::a` in constant functions + --> $DIR/const-supertrait-unstable.rs:36:7 + | +LL | x.a(); + | ^^^ + | +note: method `a` is not const because trait `Foo` is not const + --> $DIR/const-supertrait-unstable.rs:21:1 + | +LL | trait Foo { + | ^^^^^^^^^ this trait is not const +LL | fn a(&self); + | ------------ this method is not const + = help: const traits are not yet supported on stable Rust + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants + +error: aborting due to 8 previous errors + +Some errors have detailed explanations: E0015, E0554. +For more information about an error, try `rustc --explain E0015`. diff --git a/tests/ui/traits/const-traits/const-supertrait-unstable.stable.stderr b/tests/ui/traits/const-traits/const-supertrait-unstable.stable.stderr new file mode 100644 index 0000000000000..ee1c731e604a6 --- /dev/null +++ b/tests/ui/traits/const-traits/const-supertrait-unstable.stable.stderr @@ -0,0 +1,111 @@ +error: `[const]` is not allowed here + --> $DIR/const-supertrait-unstable.rs:25:12 + | +LL | trait Bar: [const] Foo {} + | ^^^^^^^ + | +note: this trait is not `const`, so it cannot have `[const]` trait bounds + --> $DIR/const-supertrait-unstable.rs:25:1 + | +LL | trait Bar: [const] Foo {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0658]: const trait impls are experimental + --> $DIR/const-supertrait-unstable.rs:25:12 + | +LL | trait Bar: [const] Foo {} + | ^^^^^^^ + | + = note: see issue #143874 for more information + +error[E0658]: const trait impls are experimental + --> $DIR/const-supertrait-unstable.rs:32:17 + | +LL | const fn foo(x: &T) { + | ^^^^^^^ + | + = note: see issue #143874 for more information + +error: `[const]` can only be applied to `const` traits + --> $DIR/const-supertrait-unstable.rs:25:12 + | +LL | trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` + | +note: `Foo` can't be used with `[const]` because it isn't `const` + --> $DIR/const-supertrait-unstable.rs:21:1 + | +LL | trait Foo { + | ^^^^^^^^^ + +error: `[const]` can only be applied to `const` traits + --> $DIR/const-supertrait-unstable.rs:25:12 + | +LL | trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` + | +note: `Foo` can't be used with `[const]` because it isn't `const` + --> $DIR/const-supertrait-unstable.rs:21:1 + | +LL | trait Foo { + | ^^^^^^^^^ + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: `[const]` can only be applied to `const` traits + --> $DIR/const-supertrait-unstable.rs:25:12 + | +LL | trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` + | +note: `Foo` can't be used with `[const]` because it isn't `const` + --> $DIR/const-supertrait-unstable.rs:21:1 + | +LL | trait Foo { + | ^^^^^^^^^ + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: `[const]` can only be applied to `const` traits + --> $DIR/const-supertrait-unstable.rs:32:17 + | +LL | const fn foo(x: &T) { + | ^^^^^^^ can't be applied to `Bar` + | +note: `Bar` can't be used with `[const]` because it isn't `const` + --> $DIR/const-supertrait-unstable.rs:25:1 + | +LL | trait Bar: [const] Foo {} + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: `[const]` can only be applied to `const` traits + --> $DIR/const-supertrait-unstable.rs:32:17 + | +LL | const fn foo(x: &T) { + | ^^^^^^^ can't be applied to `Bar` + | +note: `Bar` can't be used with `[const]` because it isn't `const` + --> $DIR/const-supertrait-unstable.rs:25:1 + | +LL | trait Bar: [const] Foo {} + | ^^^^^^^^^^^^^^^^^^^^^^ + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error[E0015]: cannot call non-const method `::a` in constant functions + --> $DIR/const-supertrait-unstable.rs:36:7 + | +LL | x.a(); + | ^^^ + | +note: method `a` is not const because trait `Foo` is not const + --> $DIR/const-supertrait-unstable.rs:21:1 + | +LL | trait Foo { + | ^^^^^^^^^ this trait is not const +LL | fn a(&self); + | ------------ this method is not const + = help: const traits are not yet supported on stable Rust + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants + +error: aborting due to 9 previous errors + +Some errors have detailed explanations: E0015, E0658. +For more information about an error, try `rustc --explain E0015`. From 30a01abf23511c40d53c32f31a3af7856ec3752c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Fri, 23 Oct 2026 16:18:15 +0200 Subject: [PATCH 3/5] Migrate the `issue-149402-no-suggest-unstable` test from a run-make test to a UI test --- .../issue-149402-suggest-unresolve/foo.rs | 6 ----- .../nightly.err | 18 ------------- .../output.diff | 16 ------------ .../issue-149402-suggest-unresolve/rmake.rs | 25 ------------------- .../dont-suggest-unstable-type.nightly.stderr | 15 +++++++++++ .../suggestions/dont-suggest-unstable-type.rs | 18 +++++++++++++ .../dont-suggest-unstable-type.stable.stderr} | 8 +++--- 7 files changed, 37 insertions(+), 69 deletions(-) delete mode 100644 tests/run-make/issue-149402-suggest-unresolve/foo.rs delete mode 100644 tests/run-make/issue-149402-suggest-unresolve/nightly.err delete mode 100644 tests/run-make/issue-149402-suggest-unresolve/output.diff delete mode 100644 tests/run-make/issue-149402-suggest-unresolve/rmake.rs create mode 100644 tests/ui/resolve/suggestions/dont-suggest-unstable-type.nightly.stderr create mode 100644 tests/ui/resolve/suggestions/dont-suggest-unstable-type.rs rename tests/{run-make/issue-149402-suggest-unresolve/stable.err => ui/resolve/suggestions/dont-suggest-unstable-type.stable.stderr} (50%) diff --git a/tests/run-make/issue-149402-suggest-unresolve/foo.rs b/tests/run-make/issue-149402-suggest-unresolve/foo.rs deleted file mode 100644 index 8456990829b4a..0000000000000 --- a/tests/run-make/issue-149402-suggest-unresolve/foo.rs +++ /dev/null @@ -1,6 +0,0 @@ -fn foo() { - let x = Vec::new(); - x.push(Complete::Item { name: "hello" }); -} - -fn main() {} diff --git a/tests/run-make/issue-149402-suggest-unresolve/nightly.err b/tests/run-make/issue-149402-suggest-unresolve/nightly.err deleted file mode 100644 index 8e122e3da388b..0000000000000 --- a/tests/run-make/issue-149402-suggest-unresolve/nightly.err +++ /dev/null @@ -1,18 +0,0 @@ -error[E0433]: cannot find type `Complete` in this scope - --> foo.rs:3:12 - | -3 | x.push(Complete::Item { name: "hello" }); - | ^^^^^^^^ use of undeclared type `Complete` - | -help: there is an enum variant `core::ops::CoroutineState::Complete` and 1 other; try using the variant's enum - | -3 - x.push(Complete::Item { name: "hello" }); -3 + x.push(core::ops::CoroutineState::Item { name: "hello" }); - | -3 - x.push(Complete::Item { name: "hello" }); -3 + x.push(std::ops::CoroutineState::Item { name: "hello" }); - | - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0433`. diff --git a/tests/run-make/issue-149402-suggest-unresolve/output.diff b/tests/run-make/issue-149402-suggest-unresolve/output.diff deleted file mode 100644 index 196c0326a7143..0000000000000 --- a/tests/run-make/issue-149402-suggest-unresolve/output.diff +++ /dev/null @@ -1,16 +0,0 @@ -@@ -3,6 +3,15 @@ - | - 3 | x.push(Complete::Item { name: "hello" }); - | ^^^^^^^^ use of undeclared type `Complete` -+ | -+help: there is an enum variant `core::ops::CoroutineState::Complete` and 1 other; try using the variant's enum -+ | -+3 - x.push(Complete::Item { name: "hello" }); -+3 + x.push(core::ops::CoroutineState::Item { name: "hello" }); -+ | -+3 - x.push(Complete::Item { name: "hello" }); -+3 + x.push(std::ops::CoroutineState::Item { name: "hello" }); -+ | - - error: aborting due to 1 previous error - diff --git a/tests/run-make/issue-149402-suggest-unresolve/rmake.rs b/tests/run-make/issue-149402-suggest-unresolve/rmake.rs deleted file mode 100644 index a8d92606ee893..0000000000000 --- a/tests/run-make/issue-149402-suggest-unresolve/rmake.rs +++ /dev/null @@ -1,25 +0,0 @@ -//! Check that unstable name-resolution suggestions are omitted on stable. -//! -//! Regression test for . -//! -//@ only-nightly -//@ needs-target-std -//@ ignore-backends: gcc - -use run_make_support::{diff, rustc, similar, stable_bare_rustc}; - -fn main() { - let stable_like = stable_bare_rustc().edition("2024").input("foo.rs").run_fail().stderr_utf8(); - - assert!(!stable_like.contains("CoroutineState::Complete")); - diff().expected_file("stable.err").actual_text("stable_like", &stable_like).run(); - - let nightly = rustc().edition("2024").input("foo.rs").run_fail().stderr_utf8(); - - assert!(nightly.contains("CoroutineState::Complete")); - diff().expected_file("nightly.err").actual_text("nightly", &nightly).run(); - - let stderr_diff = - similar::TextDiff::from_lines(&stable_like, &nightly).unified_diff().to_string(); - diff().expected_file("output.diff").actual_text("diff", stderr_diff).run(); -} diff --git a/tests/ui/resolve/suggestions/dont-suggest-unstable-type.nightly.stderr b/tests/ui/resolve/suggestions/dont-suggest-unstable-type.nightly.stderr new file mode 100644 index 0000000000000..580b870d880cd --- /dev/null +++ b/tests/ui/resolve/suggestions/dont-suggest-unstable-type.nightly.stderr @@ -0,0 +1,15 @@ +error[E0433]: cannot find type `Complete` in this scope + --> $DIR/dont-suggest-unstable-type.rs:14:12 + | +LL | x.push(Complete::Item { name: "hello" }); + | ^^^^^^^^ use of undeclared type `Complete` + | +help: there is an enum variant `std::ops::CoroutineState::Complete`; try using the variant's enum + | +LL - x.push(Complete::Item { name: "hello" }); +LL + x.push(std::ops::CoroutineState::Item { name: "hello" }); + | + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0433`. diff --git a/tests/ui/resolve/suggestions/dont-suggest-unstable-type.rs b/tests/ui/resolve/suggestions/dont-suggest-unstable-type.rs new file mode 100644 index 0000000000000..c647df2420681 --- /dev/null +++ b/tests/ui/resolve/suggestions/dont-suggest-unstable-type.rs @@ -0,0 +1,18 @@ +//! Check that unstable name-resolution suggestions are omitted on stable. +//! +//! Regression test for . +//! +//@ needs-target-std +//@ ignore-backends: gcc + +//@ revisions: stable nightly +//@[stable] act-as-stable +//@[nightly] only-nightly + +fn foo() { + let x = Vec::new(); + x.push(Complete::Item { name: "hello" }); + //~^ ERROR: cannot find type `Complete` in this scope +} + +fn main() {} diff --git a/tests/run-make/issue-149402-suggest-unresolve/stable.err b/tests/ui/resolve/suggestions/dont-suggest-unstable-type.stable.stderr similarity index 50% rename from tests/run-make/issue-149402-suggest-unresolve/stable.err rename to tests/ui/resolve/suggestions/dont-suggest-unstable-type.stable.stderr index f980d4548f64c..ca3a399d9d765 100644 --- a/tests/run-make/issue-149402-suggest-unresolve/stable.err +++ b/tests/ui/resolve/suggestions/dont-suggest-unstable-type.stable.stderr @@ -1,8 +1,8 @@ error[E0433]: cannot find type `Complete` in this scope - --> foo.rs:3:12 - | -3 | x.push(Complete::Item { name: "hello" }); - | ^^^^^^^^ use of undeclared type `Complete` + --> $DIR/dont-suggest-unstable-type.rs:14:12 + | +LL | x.push(Complete::Item { name: "hello" }); + | ^^^^^^^^ use of undeclared type `Complete` error: aborting due to 1 previous error From ababbd48cebe587658c97f872195a00a0867cb53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Fri, 23 Oct 2026 20:34:38 +0200 Subject: [PATCH 4/5] Migrate the `unstable-target-feature` test from a run-make test to a UI test --- .../run-make/unstable-target-feature/rmake.rs | 20 ------------------- .../unstable-target-feature.rs | 2 -- .../unstable-target-feature.stderr | 8 -------- .../unstable-target-feature-on-nightly.rs | 13 ++++++++++++ ...le-target-feature-on-nightly.stable.stderr | 8 ++++++++ .../const-traits/const-supertrait-unstable.rs | 2 ++ 6 files changed, 23 insertions(+), 30 deletions(-) delete mode 100644 tests/run-make/unstable-target-feature/rmake.rs delete mode 100644 tests/run-make/unstable-target-feature/unstable-target-feature.rs delete mode 100644 tests/run-make/unstable-target-feature/unstable-target-feature.stderr create mode 100644 tests/ui/target-feature/unstable-target-feature-on-nightly.rs create mode 100644 tests/ui/target-feature/unstable-target-feature-on-nightly.stable.stderr diff --git a/tests/run-make/unstable-target-feature/rmake.rs b/tests/run-make/unstable-target-feature/rmake.rs deleted file mode 100644 index 3fefe11ff791e..0000000000000 --- a/tests/run-make/unstable-target-feature/rmake.rs +++ /dev/null @@ -1,20 +0,0 @@ -//@ only-x86_64 -// FIXME: Once GCC backend is fixed, remove this `ignore-backends`. -//@ ignore-backends: gcc - -// Ensure that on stable we don't suggest restricting with an unsafe trait and we continue -// mentioning the rest of the obligation chain. - -use run_make_support::{diff, rustc}; - -fn main() { - let out = rustc() - .env("RUSTC_BOOTSTRAP", "-1") - .input("unstable-target-feature.rs") - .args(&["-Ctarget-feature=+x87", "--crate-type=rlib"]) - .run() - .assert_stderr_not_contains("help: consider restricting type parameter `T`") - .assert_stderr_contains("unstable feature") - .stderr_utf8(); - diff().expected_file("unstable-target-feature.stderr").actual_text("(stable rustc)", &out).run() -} diff --git a/tests/run-make/unstable-target-feature/unstable-target-feature.rs b/tests/run-make/unstable-target-feature/unstable-target-feature.rs deleted file mode 100644 index ec7318829e77e..0000000000000 --- a/tests/run-make/unstable-target-feature/unstable-target-feature.rs +++ /dev/null @@ -1,2 +0,0 @@ -/// Tidy is unhappy if we leave the file empty. -pub fn empty() {} diff --git a/tests/run-make/unstable-target-feature/unstable-target-feature.stderr b/tests/run-make/unstable-target-feature/unstable-target-feature.stderr deleted file mode 100644 index e4b2717f911f3..0000000000000 --- a/tests/run-make/unstable-target-feature/unstable-target-feature.stderr +++ /dev/null @@ -1,8 +0,0 @@ -warning: unstable feature specified for `-Ctarget-feature`: `x87` - | - = note: this feature is not stably supported; 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: 1 warning emitted - diff --git a/tests/ui/target-feature/unstable-target-feature-on-nightly.rs b/tests/ui/target-feature/unstable-target-feature-on-nightly.rs new file mode 100644 index 0000000000000..76b01ef42d8fa --- /dev/null +++ b/tests/ui/target-feature/unstable-target-feature-on-nightly.rs @@ -0,0 +1,13 @@ +//! Ensure that on nightly we don't warn about using unstable target features. + +//@ only-x86_64 +// FIXME: Once GCC backend is fixed, remove this `ignore-backends`. +//@ ignore-backends: gcc + +//@ compile-flags: -Ctarget-feature=+x87 --crate-type=rlib +//@ check-pass +//@ revisions: stable nightly +//@[stable] act-as-stable +//@[nightly] only-nightly + +//[stable]~? WARNING unstable feature specified for `-Ctarget-feature`: `x87` diff --git a/tests/ui/target-feature/unstable-target-feature-on-nightly.stable.stderr b/tests/ui/target-feature/unstable-target-feature-on-nightly.stable.stderr new file mode 100644 index 0000000000000..c7623519db2ed --- /dev/null +++ b/tests/ui/target-feature/unstable-target-feature-on-nightly.stable.stderr @@ -0,0 +1,8 @@ +warning: unstable feature specified for `-Ctarget-feature`: `x87` + | + = note: this feature is not stably supported; 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: 1 warning emitted + diff --git a/tests/ui/traits/const-traits/const-supertrait-unstable.rs b/tests/ui/traits/const-traits/const-supertrait-unstable.rs index 246124b570602..97b6b061526f6 100644 --- a/tests/ui/traits/const-traits/const-supertrait-unstable.rs +++ b/tests/ui/traits/const-traits/const-supertrait-unstable.rs @@ -4,7 +4,9 @@ //@ needs-target-std //@ ignore-backends: gcc +//@ normalize-stderr: "dev release channel" -> "nightly release channel" //@ compile-flags: --check-cfg=cfg(feature_enabled) + //@ revisions: stable stable-enabled nightly nightly-enabled //@[stable] act-as-stable //@[stable-enabled] act-as-stable From cbdd3f36585d9747c9614b10e59696632e0e64fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Sun, 25 Oct 2026 13:07:12 +0100 Subject: [PATCH 5/5] Also normalize "stable release channel" --- ...supertrait-unstable.nightly-enabled.stderr | 18 +++++------ .../const-supertrait-unstable.nightly.stderr | 22 ++++++------- .../const-traits/const-supertrait-unstable.rs | 1 + ...-supertrait-unstable.stable-enabled.stderr | 30 ++++++++--------- .../const-supertrait-unstable.stable.stderr | 32 +++++++++---------- 5 files changed, 52 insertions(+), 51 deletions(-) diff --git a/tests/ui/traits/const-traits/const-supertrait-unstable.nightly-enabled.stderr b/tests/ui/traits/const-traits/const-supertrait-unstable.nightly-enabled.stderr index 43ac8df50d8f1..ae38e9799981f 100644 --- a/tests/ui/traits/const-traits/const-supertrait-unstable.nightly-enabled.stderr +++ b/tests/ui/traits/const-traits/const-supertrait-unstable.nightly-enabled.stderr @@ -1,17 +1,17 @@ error: `[const]` is not allowed here - --> $DIR/const-supertrait-unstable.rs:25:12 + --> $DIR/const-supertrait-unstable.rs:26:12 | LL | trait Bar: [const] Foo {} | ^^^^^^^ | note: this trait is not `const`, so it cannot have `[const]` trait bounds - --> $DIR/const-supertrait-unstable.rs:25:1 + --> $DIR/const-supertrait-unstable.rs:26:1 | LL | trait Bar: [const] Foo {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: `[const]` can only be applied to `const` traits - --> $DIR/const-supertrait-unstable.rs:25:12 + --> $DIR/const-supertrait-unstable.rs:26:12 | LL | trait Bar: [const] Foo {} | ^^^^^^^ can't be applied to `Foo` @@ -22,7 +22,7 @@ LL | const trait Foo { | +++++ error: `[const]` can only be applied to `const` traits - --> $DIR/const-supertrait-unstable.rs:25:12 + --> $DIR/const-supertrait-unstable.rs:26:12 | LL | trait Bar: [const] Foo {} | ^^^^^^^ can't be applied to `Foo` @@ -34,7 +34,7 @@ LL | const trait Foo { | +++++ error: `[const]` can only be applied to `const` traits - --> $DIR/const-supertrait-unstable.rs:25:12 + --> $DIR/const-supertrait-unstable.rs:26:12 | LL | trait Bar: [const] Foo {} | ^^^^^^^ can't be applied to `Foo` @@ -46,7 +46,7 @@ LL | const trait Foo { | +++++ error: `[const]` can only be applied to `const` traits - --> $DIR/const-supertrait-unstable.rs:32:17 + --> $DIR/const-supertrait-unstable.rs:33:17 | LL | const fn foo(x: &T) { | ^^^^^^^ can't be applied to `Bar` @@ -57,7 +57,7 @@ LL | const trait Bar: [const] Foo {} | +++++ error: `[const]` can only be applied to `const` traits - --> $DIR/const-supertrait-unstable.rs:32:17 + --> $DIR/const-supertrait-unstable.rs:33:17 | LL | const fn foo(x: &T) { | ^^^^^^^ can't be applied to `Bar` @@ -69,13 +69,13 @@ LL | const trait Bar: [const] Foo {} | +++++ error[E0015]: cannot call non-const method `::a` in constant functions - --> $DIR/const-supertrait-unstable.rs:36:7 + --> $DIR/const-supertrait-unstable.rs:37:7 | LL | x.a(); | ^^^ | note: method `a` is not const because trait `Foo` is not const - --> $DIR/const-supertrait-unstable.rs:21:1 + --> $DIR/const-supertrait-unstable.rs:22:1 | LL | trait Foo { | ^^^^^^^^^ this trait is not const diff --git a/tests/ui/traits/const-traits/const-supertrait-unstable.nightly.stderr b/tests/ui/traits/const-traits/const-supertrait-unstable.nightly.stderr index ed1fa6bf261a9..ba0c399c0d27b 100644 --- a/tests/ui/traits/const-traits/const-supertrait-unstable.nightly.stderr +++ b/tests/ui/traits/const-traits/const-supertrait-unstable.nightly.stderr @@ -1,17 +1,17 @@ error: `[const]` is not allowed here - --> $DIR/const-supertrait-unstable.rs:25:12 + --> $DIR/const-supertrait-unstable.rs:26:12 | LL | trait Bar: [const] Foo {} | ^^^^^^^ | note: this trait is not `const`, so it cannot have `[const]` trait bounds - --> $DIR/const-supertrait-unstable.rs:25:1 + --> $DIR/const-supertrait-unstable.rs:26:1 | LL | trait Bar: [const] Foo {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0658]: const trait impls are experimental - --> $DIR/const-supertrait-unstable.rs:25:12 + --> $DIR/const-supertrait-unstable.rs:26:12 | LL | trait Bar: [const] Foo {} | ^^^^^^^ @@ -21,7 +21,7 @@ LL | trait Bar: [const] Foo {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: const trait impls are experimental - --> $DIR/const-supertrait-unstable.rs:32:17 + --> $DIR/const-supertrait-unstable.rs:33:17 | LL | const fn foo(x: &T) { | ^^^^^^^ @@ -31,7 +31,7 @@ LL | const fn foo(x: &T) { = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error: `[const]` can only be applied to `const` traits - --> $DIR/const-supertrait-unstable.rs:25:12 + --> $DIR/const-supertrait-unstable.rs:26:12 | LL | trait Bar: [const] Foo {} | ^^^^^^^ can't be applied to `Foo` @@ -42,7 +42,7 @@ LL | const trait Foo { | +++++ error: `[const]` can only be applied to `const` traits - --> $DIR/const-supertrait-unstable.rs:25:12 + --> $DIR/const-supertrait-unstable.rs:26:12 | LL | trait Bar: [const] Foo {} | ^^^^^^^ can't be applied to `Foo` @@ -54,7 +54,7 @@ LL | const trait Foo { | +++++ error: `[const]` can only be applied to `const` traits - --> $DIR/const-supertrait-unstable.rs:25:12 + --> $DIR/const-supertrait-unstable.rs:26:12 | LL | trait Bar: [const] Foo {} | ^^^^^^^ can't be applied to `Foo` @@ -66,7 +66,7 @@ LL | const trait Foo { | +++++ error: `[const]` can only be applied to `const` traits - --> $DIR/const-supertrait-unstable.rs:32:17 + --> $DIR/const-supertrait-unstable.rs:33:17 | LL | const fn foo(x: &T) { | ^^^^^^^ can't be applied to `Bar` @@ -77,7 +77,7 @@ LL | const trait Bar: [const] Foo {} | +++++ error: `[const]` can only be applied to `const` traits - --> $DIR/const-supertrait-unstable.rs:32:17 + --> $DIR/const-supertrait-unstable.rs:33:17 | LL | const fn foo(x: &T) { | ^^^^^^^ can't be applied to `Bar` @@ -89,13 +89,13 @@ LL | const trait Bar: [const] Foo {} | +++++ error[E0015]: cannot call non-const method `::a` in constant functions - --> $DIR/const-supertrait-unstable.rs:36:7 + --> $DIR/const-supertrait-unstable.rs:37:7 | LL | x.a(); | ^^^ | note: method `a` is not const because trait `Foo` is not const - --> $DIR/const-supertrait-unstable.rs:21:1 + --> $DIR/const-supertrait-unstable.rs:22:1 | LL | trait Foo { | ^^^^^^^^^ this trait is not const diff --git a/tests/ui/traits/const-traits/const-supertrait-unstable.rs b/tests/ui/traits/const-traits/const-supertrait-unstable.rs index 97b6b061526f6..0d70a4b876d9b 100644 --- a/tests/ui/traits/const-traits/const-supertrait-unstable.rs +++ b/tests/ui/traits/const-traits/const-supertrait-unstable.rs @@ -5,6 +5,7 @@ //@ ignore-backends: gcc //@ normalize-stderr: "dev release channel" -> "nightly release channel" +//@ normalize-stderr: "stable release channel" -> "nightly release channel" //@ compile-flags: --check-cfg=cfg(feature_enabled) //@ revisions: stable stable-enabled nightly nightly-enabled diff --git a/tests/ui/traits/const-traits/const-supertrait-unstable.stable-enabled.stderr b/tests/ui/traits/const-traits/const-supertrait-unstable.stable-enabled.stderr index dbcc8d46d3fc7..196f3dc2724ba 100644 --- a/tests/ui/traits/const-traits/const-supertrait-unstable.stable-enabled.stderr +++ b/tests/ui/traits/const-traits/const-supertrait-unstable.stable-enabled.stderr @@ -1,92 +1,92 @@ error: `[const]` is not allowed here - --> $DIR/const-supertrait-unstable.rs:25:12 + --> $DIR/const-supertrait-unstable.rs:26:12 | LL | trait Bar: [const] Foo {} | ^^^^^^^ | note: this trait is not `const`, so it cannot have `[const]` trait bounds - --> $DIR/const-supertrait-unstable.rs:25:1 + --> $DIR/const-supertrait-unstable.rs:26:1 | LL | trait Bar: [const] Foo {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0554]: `#![feature]` may not be used on the nightly release channel - --> $DIR/const-supertrait-unstable.rs:18:30 + --> $DIR/const-supertrait-unstable.rs:19:30 | LL | #![cfg_attr(feature_enabled, feature(const_trait_impl))] | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: `[const]` can only be applied to `const` traits - --> $DIR/const-supertrait-unstable.rs:25:12 + --> $DIR/const-supertrait-unstable.rs:26:12 | LL | trait Bar: [const] Foo {} | ^^^^^^^ can't be applied to `Foo` | note: `Foo` can't be used with `[const]` because it isn't `const` - --> $DIR/const-supertrait-unstable.rs:21:1 + --> $DIR/const-supertrait-unstable.rs:22:1 | LL | trait Foo { | ^^^^^^^^^ error: `[const]` can only be applied to `const` traits - --> $DIR/const-supertrait-unstable.rs:25:12 + --> $DIR/const-supertrait-unstable.rs:26:12 | LL | trait Bar: [const] Foo {} | ^^^^^^^ can't be applied to `Foo` | note: `Foo` can't be used with `[const]` because it isn't `const` - --> $DIR/const-supertrait-unstable.rs:21:1 + --> $DIR/const-supertrait-unstable.rs:22:1 | LL | trait Foo { | ^^^^^^^^^ = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: `[const]` can only be applied to `const` traits - --> $DIR/const-supertrait-unstable.rs:25:12 + --> $DIR/const-supertrait-unstable.rs:26:12 | LL | trait Bar: [const] Foo {} | ^^^^^^^ can't be applied to `Foo` | note: `Foo` can't be used with `[const]` because it isn't `const` - --> $DIR/const-supertrait-unstable.rs:21:1 + --> $DIR/const-supertrait-unstable.rs:22:1 | LL | trait Foo { | ^^^^^^^^^ = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: `[const]` can only be applied to `const` traits - --> $DIR/const-supertrait-unstable.rs:32:17 + --> $DIR/const-supertrait-unstable.rs:33:17 | LL | const fn foo(x: &T) { | ^^^^^^^ can't be applied to `Bar` | note: `Bar` can't be used with `[const]` because it isn't `const` - --> $DIR/const-supertrait-unstable.rs:25:1 + --> $DIR/const-supertrait-unstable.rs:26:1 | LL | trait Bar: [const] Foo {} | ^^^^^^^^^^^^^^^^^^^^^^ error: `[const]` can only be applied to `const` traits - --> $DIR/const-supertrait-unstable.rs:32:17 + --> $DIR/const-supertrait-unstable.rs:33:17 | LL | const fn foo(x: &T) { | ^^^^^^^ can't be applied to `Bar` | note: `Bar` can't be used with `[const]` because it isn't `const` - --> $DIR/const-supertrait-unstable.rs:25:1 + --> $DIR/const-supertrait-unstable.rs:26:1 | LL | trait Bar: [const] Foo {} | ^^^^^^^^^^^^^^^^^^^^^^ = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0015]: cannot call non-const method `::a` in constant functions - --> $DIR/const-supertrait-unstable.rs:36:7 + --> $DIR/const-supertrait-unstable.rs:37:7 | LL | x.a(); | ^^^ | note: method `a` is not const because trait `Foo` is not const - --> $DIR/const-supertrait-unstable.rs:21:1 + --> $DIR/const-supertrait-unstable.rs:22:1 | LL | trait Foo { | ^^^^^^^^^ this trait is not const diff --git a/tests/ui/traits/const-traits/const-supertrait-unstable.stable.stderr b/tests/ui/traits/const-traits/const-supertrait-unstable.stable.stderr index ee1c731e604a6..50ceda54258c1 100644 --- a/tests/ui/traits/const-traits/const-supertrait-unstable.stable.stderr +++ b/tests/ui/traits/const-traits/const-supertrait-unstable.stable.stderr @@ -1,17 +1,17 @@ error: `[const]` is not allowed here - --> $DIR/const-supertrait-unstable.rs:25:12 + --> $DIR/const-supertrait-unstable.rs:26:12 | LL | trait Bar: [const] Foo {} | ^^^^^^^ | note: this trait is not `const`, so it cannot have `[const]` trait bounds - --> $DIR/const-supertrait-unstable.rs:25:1 + --> $DIR/const-supertrait-unstable.rs:26:1 | LL | trait Bar: [const] Foo {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0658]: const trait impls are experimental - --> $DIR/const-supertrait-unstable.rs:25:12 + --> $DIR/const-supertrait-unstable.rs:26:12 | LL | trait Bar: [const] Foo {} | ^^^^^^^ @@ -19,7 +19,7 @@ LL | trait Bar: [const] Foo {} = note: see issue #143874 for more information error[E0658]: const trait impls are experimental - --> $DIR/const-supertrait-unstable.rs:32:17 + --> $DIR/const-supertrait-unstable.rs:33:17 | LL | const fn foo(x: &T) { | ^^^^^^^ @@ -27,76 +27,76 @@ LL | const fn foo(x: &T) { = note: see issue #143874 for more information error: `[const]` can only be applied to `const` traits - --> $DIR/const-supertrait-unstable.rs:25:12 + --> $DIR/const-supertrait-unstable.rs:26:12 | LL | trait Bar: [const] Foo {} | ^^^^^^^ can't be applied to `Foo` | note: `Foo` can't be used with `[const]` because it isn't `const` - --> $DIR/const-supertrait-unstable.rs:21:1 + --> $DIR/const-supertrait-unstable.rs:22:1 | LL | trait Foo { | ^^^^^^^^^ error: `[const]` can only be applied to `const` traits - --> $DIR/const-supertrait-unstable.rs:25:12 + --> $DIR/const-supertrait-unstable.rs:26:12 | LL | trait Bar: [const] Foo {} | ^^^^^^^ can't be applied to `Foo` | note: `Foo` can't be used with `[const]` because it isn't `const` - --> $DIR/const-supertrait-unstable.rs:21:1 + --> $DIR/const-supertrait-unstable.rs:22:1 | LL | trait Foo { | ^^^^^^^^^ = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: `[const]` can only be applied to `const` traits - --> $DIR/const-supertrait-unstable.rs:25:12 + --> $DIR/const-supertrait-unstable.rs:26:12 | LL | trait Bar: [const] Foo {} | ^^^^^^^ can't be applied to `Foo` | note: `Foo` can't be used with `[const]` because it isn't `const` - --> $DIR/const-supertrait-unstable.rs:21:1 + --> $DIR/const-supertrait-unstable.rs:22:1 | LL | trait Foo { | ^^^^^^^^^ = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: `[const]` can only be applied to `const` traits - --> $DIR/const-supertrait-unstable.rs:32:17 + --> $DIR/const-supertrait-unstable.rs:33:17 | LL | const fn foo(x: &T) { | ^^^^^^^ can't be applied to `Bar` | note: `Bar` can't be used with `[const]` because it isn't `const` - --> $DIR/const-supertrait-unstable.rs:25:1 + --> $DIR/const-supertrait-unstable.rs:26:1 | LL | trait Bar: [const] Foo {} | ^^^^^^^^^^^^^^^^^^^^^^ error: `[const]` can only be applied to `const` traits - --> $DIR/const-supertrait-unstable.rs:32:17 + --> $DIR/const-supertrait-unstable.rs:33:17 | LL | const fn foo(x: &T) { | ^^^^^^^ can't be applied to `Bar` | note: `Bar` can't be used with `[const]` because it isn't `const` - --> $DIR/const-supertrait-unstable.rs:25:1 + --> $DIR/const-supertrait-unstable.rs:26:1 | LL | trait Bar: [const] Foo {} | ^^^^^^^^^^^^^^^^^^^^^^ = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0015]: cannot call non-const method `::a` in constant functions - --> $DIR/const-supertrait-unstable.rs:36:7 + --> $DIR/const-supertrait-unstable.rs:37:7 | LL | x.a(); | ^^^ | note: method `a` is not const because trait `Foo` is not const - --> $DIR/const-supertrait-unstable.rs:21:1 + --> $DIR/const-supertrait-unstable.rs:22:1 | LL | trait Foo { | ^^^^^^^^^ this trait is not const