Add regression test for 125877

This commit is contained in:
reddevilmidzy 2025-05-09 02:26:01 +09:00
parent e964ccafed
commit b67549edd3
2 changed files with 53 additions and 0 deletions

View file

@ -0,0 +1,32 @@
// This test demonstrates an ICE that may occur when we try to resolve the instance
// of a impl that has different generics than the trait it's implementing. This ensures
// we first check that the args are compatible before resolving the body, just like
// we do in projection before substituting a GAT.
//
// Regression test for issue #125877.
//@ compile-flags: -Znext-solver
#![feature(const_trait_impl, effects)]
//~^ ERROR feature has been removed
#[const_trait]
trait Main {
fn compute<T: ~const Aux>() -> u32;
}
impl const Main for () {
fn compute<'x>() -> u32 {
//~^ ERROR associated function `compute` has 0 type parameters but its trait declaration has 1 type parameter
0
}
}
#[const_trait]
trait Aux {}
impl const Aux for () {}
fn main() {
const _: u32 = <()>::compute::<()>();
}

View file

@ -0,0 +1,21 @@
error[E0557]: feature has been removed
--> $DIR/const-trait-impl-parameter-mismatch.rs:10:30
|
LL | #![feature(const_trait_impl, effects)]
| ^^^^^^^ feature has been removed
|
= note: removed, redundant with `#![feature(const_trait_impl)]`
error[E0049]: associated function `compute` has 0 type parameters but its trait declaration has 1 type parameter
--> $DIR/const-trait-impl-parameter-mismatch.rs:19:16
|
LL | fn compute<T: ~const Aux>() -> u32;
| - expected 1 type parameter
...
LL | fn compute<'x>() -> u32 {
| ^^ found 0 type parameters
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0049, E0557.
For more information about an error, try `rustc --explain E0049`.