Rollup merge of #150728 - fee1-dead-contrib:const-traits-test-cleanup, r=fmease

Cleanup some ui tests for const-traits

r? project-const-traits

These tests pretty much behave as expected now.
This commit is contained in:
Matthias Krüger 2026-01-06 18:43:30 +01:00 committed by GitHub
commit 799c06fa9a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 35 additions and 212 deletions

View file

@ -1,5 +1,4 @@
//@ known-bug: #110395
//@ compile-flags: -Znext-solver
//@ check-pass
#![allow(incomplete_features)]
#![feature(const_trait_impl, generic_const_exprs)]

View file

@ -1,95 +0,0 @@
error: `-Znext-solver=globally` and `generic_const_exprs` are incompatible, using them at the same time is not allowed
--> $DIR/issue-88119.rs:4:30
|
LL | #![feature(const_trait_impl, generic_const_exprs)]
| ^^^^^^^^^^^^^^^^^^^
|
= help: remove one of these features
error[E0275]: overflow evaluating the requirement `&T: [const] ConstName`
--> $DIR/issue-88119.rs:18:49
|
LL | impl<T: ?Sized + ConstName> const ConstName for &T
| ^^
error[E0275]: overflow evaluating the requirement `&T: ConstName`
--> $DIR/issue-88119.rs:18:49
|
LL | impl<T: ?Sized + ConstName> const ConstName for &T
| ^^
error[E0275]: overflow evaluating the requirement `[(); name_len::<T>()] well-formed`
--> $DIR/issue-88119.rs:20:5
|
LL | [(); name_len::<T>()]:,
| ^^^^^^^^^^^^^^^^^^^^^
|
note: required by a bound in `<&T as ConstName>`
--> $DIR/issue-88119.rs:20:5
|
LL | [(); name_len::<T>()]:,
| ^^^^^^^^^^^^^^^^^^^^^ required by this bound in `<&T as ConstName>`
error[E0275]: overflow evaluating the requirement `[(); name_len::<T>()] well-formed`
--> $DIR/issue-88119.rs:20:10
|
LL | [(); name_len::<T>()]:,
| ^^^^^^^^^^^^^^^
|
note: required by a bound in `<&T as ConstName>`
--> $DIR/issue-88119.rs:20:5
|
LL | [(); name_len::<T>()]:,
| ^^^^^^^^^^^^^^^^^^^^^ required by this bound in `<&T as ConstName>`
error[E0275]: overflow evaluating the requirement `&mut T: [const] ConstName`
--> $DIR/issue-88119.rs:25:49
|
LL | impl<T: ?Sized + ConstName> const ConstName for &mut T
| ^^^^^^
error[E0275]: overflow evaluating the requirement `&mut T: ConstName`
--> $DIR/issue-88119.rs:25:49
|
LL | impl<T: ?Sized + ConstName> const ConstName for &mut T
| ^^^^^^
error[E0275]: overflow evaluating the requirement `[(); name_len::<T>()] well-formed`
--> $DIR/issue-88119.rs:27:5
|
LL | [(); name_len::<T>()]:,
| ^^^^^^^^^^^^^^^^^^^^^
|
note: required by a bound in `<&mut T as ConstName>`
--> $DIR/issue-88119.rs:27:5
|
LL | [(); name_len::<T>()]:,
| ^^^^^^^^^^^^^^^^^^^^^ required by this bound in `<&mut T as ConstName>`
error[E0275]: overflow evaluating the requirement `[(); name_len::<T>()] well-formed`
--> $DIR/issue-88119.rs:27:10
|
LL | [(); name_len::<T>()]:,
| ^^^^^^^^^^^^^^^
|
note: required by a bound in `<&mut T as ConstName>`
--> $DIR/issue-88119.rs:27:5
|
LL | [(); name_len::<T>()]:,
| ^^^^^^^^^^^^^^^^^^^^^ required by this bound in `<&mut T as ConstName>`
error[E0275]: overflow evaluating the requirement `&&mut u8: ConstName`
--> $DIR/issue-88119.rs:32:35
|
LL | pub const ICE_1: &'static [u8] = <&&mut u8 as ConstName>::NAME_BYTES;
| ^^^^^^^^
error[E0275]: overflow evaluating the requirement `&mut &u8: ConstName`
--> $DIR/issue-88119.rs:33:35
|
LL | pub const ICE_2: &'static [u8] = <&mut &u8 as ConstName>::NAME_BYTES;
| ^^^^^^^^
error: aborting due to 11 previous errors
For more information about this error, try `rustc --explain E0275`.

View file

@ -1,11 +0,0 @@
error: const `impl` for trait `Debug` which is not `const`
--> $DIR/rustc-impl-const-stability.rs:15:12
|
LL | impl const std::fmt::Debug for Data {
| ^^^^^^^^^^^^^^^ this trait is not `const`
|
= note: marking a trait with `const` ensures all default method bodies are `const`
= note: adding a non-const method body in the future would be a breaking change
error: aborting due to 1 previous error

View file

@ -1,59 +0,0 @@
error: `[const]` can only be applied to `const` traits
--> $DIR/const_trait_impl.rs:33:9
|
LL | impl<T: [const] Debug> const A for T {
| ^^^^^^^ can't be applied to `Debug`
|
note: `Debug` can't be used with `[const]` because it isn't `const`
--> $SRC_DIR/core/src/fmt/mod.rs:LL:COL
error: `[const]` can only be applied to `const` traits
--> $DIR/const_trait_impl.rs:39:9
|
LL | impl<T: [const] Debug + [const] Sup> const A for T {
| ^^^^^^^ can't be applied to `Debug`
|
note: `Debug` can't be used with `[const]` because it isn't `const`
--> $SRC_DIR/core/src/fmt/mod.rs:LL:COL
error: `[const]` can only be applied to `const` traits
--> $DIR/const_trait_impl.rs:45:9
|
LL | impl<T: [const] Debug + [const] Sub> const A for T {
| ^^^^^^^ can't be applied to `Debug`
|
note: `Debug` can't be used with `[const]` because it isn't `const`
--> $SRC_DIR/core/src/fmt/mod.rs:LL:COL
error: `[const]` can only be applied to `const` traits
--> $DIR/const_trait_impl.rs:39:9
|
LL | impl<T: [const] Debug + [const] Sup> const A for T {
| ^^^^^^^ can't be applied to `Debug`
|
note: `Debug` can't be used with `[const]` because it isn't `const`
--> $SRC_DIR/core/src/fmt/mod.rs:LL:COL
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: `[const]` can only be applied to `const` traits
--> $DIR/const_trait_impl.rs:33:9
|
LL | impl<T: [const] Debug> const A for T {
| ^^^^^^^ can't be applied to `Debug`
|
note: `Debug` can't be used with `[const]` because it isn't `const`
--> $SRC_DIR/core/src/fmt/mod.rs:LL:COL
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: `[const]` can only be applied to `const` traits
--> $DIR/const_trait_impl.rs:45:9
|
LL | impl<T: [const] Debug + [const] Sub> const A for T {
| ^^^^^^^ can't be applied to `Debug`
|
note: `Debug` can't be used with `[const]` because it isn't `const`
--> $SRC_DIR/core/src/fmt/mod.rs:LL:COL
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: aborting due to 6 previous errors

View file

@ -1,15 +1,15 @@
//@ known-bug: #110395
#![feature(derive_const)]
#![feature(const_default, derive_const)]
pub struct A;
impl std::fmt::Debug for A {
fn fmt(&self, _: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
panic!()
impl Default for A {
fn default() -> A {
A
}
}
#[derive_const(Debug)]
#[derive_const(Default)]
pub struct S(A);
//~^ ERROR: cannot call non-const associated function
fn main() {}

View file

@ -1,20 +1,13 @@
error: const `impl` for trait `Debug` which is not `const`
--> $DIR/derive-const-non-const-type.rs:12:16
error[E0015]: cannot call non-const associated function `<A as Default>::default` in constant functions
--> $DIR/derive-const-non-const-type.rs:12:14
|
LL | #[derive_const(Debug)]
| ^^^^^ this trait is not `const`
|
= note: marking a trait with `const` ensures all default method bodies are `const`
= note: adding a non-const method body in the future would be a breaking change
error[E0015]: cannot call non-const method `Formatter::<'_>::debug_tuple_field1_finish` in constant functions
--> $DIR/derive-const-non-const-type.rs:12:16
|
LL | #[derive_const(Debug)]
| ^^^^^
LL | #[derive_const(Default)]
| ------- in this derive macro expansion
LL | pub struct S(A);
| ^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
error: aborting due to 2 previous errors
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0015`.

View file

@ -1,5 +1,4 @@
//@ compile-flags: -Znext-solver
//@ known-bug: #110395
//@ check-pass
#![crate_type = "lib"]
#![feature(staged_api, const_trait_impl, const_default)]
@ -12,8 +11,8 @@ pub struct Data {
#[stable(feature = "potato", since = "1.27.0")]
#[rustc_const_unstable(feature = "data_foo", issue = "none")]
impl const std::fmt::Debug for Data {
fn fmt(&self, _: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
Ok(())
impl const Default for Data {
fn default() -> Data {
Data { _data: 0xbeef }
}
}

View file

@ -1,7 +1,5 @@
// Tests that trait bounds on specializing trait impls must be `[const]` if the
// same bound is present on the default impl and is `[const]` there.
//@ known-bug: #110395
// FIXME(const_trait_impl) ^ should error
#![feature(const_trait_impl)]
#![feature(rustc_attrs)]
@ -23,9 +21,9 @@ where
default fn bar() {}
}
impl<T> Bar for T
impl<T> Bar for T //~ ERROR conflicting implementations of trait `Bar`
where
T: Foo, //FIXME ~ ERROR missing `[const]` qualifier
T: Foo,
T: Specialize,
{
fn bar() {}
@ -42,7 +40,7 @@ where
default fn baz() {}
}
impl<T> const Baz for T //FIXME ~ ERROR conflicting implementations of trait `Baz`
impl<T> const Baz for T //~ ERROR conflicting implementations of trait `Baz`
where
T: Foo,
T: Specialize,

View file

@ -1,5 +1,5 @@
error[E0119]: conflicting implementations of trait `Bar`
--> $DIR/const-default-bound-non-const-specialized-bound.rs:26:1
--> $DIR/const-default-bound-non-const-specialized-bound.rs:24:1
|
LL | / impl<T> const Bar for T
LL | | where
@ -8,19 +8,19 @@ LL | | T: [const] Foo,
...
LL | / impl<T> Bar for T
LL | | where
LL | | T: Foo, //FIXME ~ ERROR missing `[const]` qualifier
LL | | T: Foo,
LL | | T: Specialize,
| |__________________^ conflicting implementation
error[E0119]: conflicting implementations of trait `Baz`
--> $DIR/const-default-bound-non-const-specialized-bound.rs:45:1
--> $DIR/const-default-bound-non-const-specialized-bound.rs:43:1
|
LL | / impl<T> const Baz for T
LL | | where
LL | | T: [const] Foo,
| |___________________- first implementation here
...
LL | / impl<T> const Baz for T //FIXME ~ ERROR conflicting implementations of trait `Baz`
LL | / impl<T> const Baz for T
LL | | where
LL | | T: Foo,
LL | | T: Specialize,

View file

@ -1,8 +1,6 @@
//@ known-bug: #110395
#![feature(const_trait_impl, min_specialization, rustc_attrs)]
use std::fmt::Debug;
//@ check-pass
#![feature(const_trait_impl, const_default, min_specialization, rustc_attrs)]
#![allow(internal_features)]
#[rustc_specialization_trait]
pub const unsafe trait Sup {
@ -30,19 +28,19 @@ pub const trait A {
fn a() -> u32;
}
impl<T: [const] Debug> const A for T {
impl<T: [const] Default> const A for T {
default fn a() -> u32 {
2
}
}
impl<T: [const] Debug + [const] Sup> const A for T {
impl<T: [const] Default + [const] Sup> const A for T {
default fn a() -> u32 {
3
}
}
impl<T: [const] Debug + [const] Sub> const A for T {
impl<T: [const] Default + [const] Sub> const A for T {
fn a() -> u32 {
T::foo()
}

View file

@ -1,5 +1,6 @@
#![feature(const_trait_impl, min_specialization, rustc_attrs)]
//@ known-bug: #110395
#![allow(internal_features)]
#[rustc_specialization_trait]
pub const trait Sup {}
@ -23,7 +24,7 @@ impl<T: Default + [const] Sup> const A for T {
const fn generic<T: Default>() {
<T as A>::a();
//FIXME ~^ ERROR: the trait bound `T: [const] Sup` is not satisfied
//~^ ERROR: the trait bound `T: [const] A` is not satisfied
}
fn main() {}

View file

@ -1,5 +1,5 @@
error[E0277]: the trait bound `T: [const] A` is not satisfied
--> $DIR/specializing-constness-2.rs:25:6
--> $DIR/specializing-constness-2.rs:26:6
|
LL | <T as A>::a();
| ^