Skip to content

Commit d63e457

Browse files
authored
Rollup merge of #163114 - zakrad:regr-test-143018, r=camelid
Add regression test for hang on mutually recursive trait impls Fixes #143018, it no longer hangs, it hung on nightlies through 2026-08-08 and terminates with an error from 2026-08-11
2 parents a4a2aae + dddede5 commit d63e457

3 files changed

Lines changed: 53 additions & 0 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0282]: type annotations needed
2+
--> $DIR/mutually-recursive-impls-hang-143018.rs:26:5
3+
|
4+
LL | impls_trait::<A, _>();
5+
| ^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `V` declared on the function `impls_trait`
6+
7+
error: aborting due to 1 previous error
8+
9+
For more information about this error, try `rustc --explain E0282`.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error[E0275]: overflow evaluating the requirement `A: Trait<_>`
2+
--> $DIR/mutually-recursive-impls-hang-143018.rs:26:19
3+
|
4+
LL | impls_trait::<A, _>();
5+
| ^
6+
|
7+
note: required by a bound in `impls_trait`
8+
--> $DIR/mutually-recursive-impls-hang-143018.rs:24:19
9+
|
10+
LL | fn impls_trait<T: Trait<V>, V>() {}
11+
| ^^^^^^^^ required by this bound in `impls_trait`
12+
13+
error: aborting due to 1 previous error
14+
15+
For more information about this error, try `rustc --explain E0275`.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//@ revisions: current next
2+
//@ ignore-compare-mode-next-solver (explicit revisions)
3+
//@[next] compile-flags: -Znext-solver
4+
5+
// Regression test for <https://github.com/rust-lang/rust/issues/143018>.
6+
7+
trait Trait<V> {}
8+
struct A;
9+
struct B;
10+
11+
impl<V> Trait<V> for A
12+
where
13+
A: Trait<V>,
14+
B: Trait<V>,
15+
{
16+
}
17+
18+
impl<V> Trait<V> for B
19+
where
20+
A: Trait<V>,
21+
{
22+
}
23+
24+
fn impls_trait<T: Trait<V>, V>() {}
25+
fn main() {
26+
impls_trait::<A, _>();
27+
//[current]~^ ERROR type annotations needed
28+
//[next]~^^ ERROR overflow evaluating the requirement
29+
}

0 commit comments

Comments
 (0)