Skip to content

Add regression test for 125877 #140819

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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::<()>();
}
Original file line number Diff line number Diff line change
@@ -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`.
Loading