Skip to content

Commit 6a2ec50

Browse files
committed
add normalization test with defaulted type param with diverging alias
Another example from rust-lang/trait-system-refactor-initiative#139 and which was fixed in 1.89 `nightly-2025-06-18`.
1 parent 71a7ac1 commit 6a2ec50

3 files changed

Lines changed: 39 additions & 0 deletions
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0275]: overflow evaluating the requirement `<u8 as Trait>::Diverges<u8> == _`
2+
--> $DIR/normalize-diverging-alias-in-defaulted-type-parameter.rs:17:12
3+
|
4+
LL | struct Bar<T: ?Sized = <u8 as Trait>::Diverges<u8>>(Box<T>);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
7+
error: aborting due to 1 previous error
8+
9+
For more information about this error, try `rustc --explain E0275`.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0271]: type mismatch resolving `<u8 as Trait>::Diverges<u8> normalizes-to _`
2+
--> $DIR/normalize-diverging-alias-in-defaulted-type-parameter.rs:17:12
3+
|
4+
LL | struct Bar<T: ?Sized = <u8 as Trait>::Diverges<u8>>(Box<T>);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ types differ
6+
7+
error: aborting due to 1 previous error
8+
9+
For more information about this error, try `rustc --explain E0271`.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Ensure that defaulted type parameters whose default contains diverging aliases are properly
2+
// caught with both solvers.
3+
// MCVE from https://github.com/rust-lang/trait-system-refactor-initiative/issues/139#issuecomment-2704576249.
4+
5+
//@ revisions: current next
6+
//@ ignore-compare-mode-next-solver (explicit revisions)
7+
//@ [next] compile-flags: -Znext-solver
8+
9+
trait Trait {
10+
type Diverges<D: Trait>;
11+
}
12+
13+
impl<T> Trait for T {
14+
type Diverges<D: Trait> = D::Diverges<D>;
15+
}
16+
17+
struct Bar<T: ?Sized = <u8 as Trait>::Diverges<u8>>(Box<T>);
18+
//[current]~^ ERROR: overflow evaluating the requirement `<u8 as Trait>::Diverges<u8> == _`
19+
//[next]~^^ ERROR: type mismatch resolving `<u8 as Trait>::Diverges<u8> normalizes-to _`
20+
21+
fn main() {}

0 commit comments

Comments
 (0)