Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
@@ -1,5 +1,5 @@
error: overflow evaluating associated type `T::This`
--> $DIR/normalization-overflow.rs:9:5
--> $DIR/normalization-overflow.rs:14:5
|
LL | type This = Self::This;
| ^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
error[E0271]: type mismatch resolving `T::This normalizes-to _`
--> $DIR/normalization-overflow.rs:14:5
|
LL | type This = Self::This;
| ^^^^^^^^^ types differ

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0271`.
11 changes: 9 additions & 2 deletions tests/ui/associated-inherent-types/normalization-overflow.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
#![feature(inherent_associated_types)]
//@ revisions: current next
//@ ignore-compare-mode-next-solver (explicit revisions)
//@ [next] compile-flags: -Znext-solver

#![feature(inherent_associated_types, rustc_attrs)]
#![allow(incomplete_features)]
#![rustc_no_implicit_bounds]

// FIXME(fmease): I'd prefer to report a cycle error here instead of an overflow one.

struct T;

impl T {
type This = Self::This; //~ ERROR overflow evaluating associated type `T::This`
type This = Self::This;
//[current]~^ ERROR: overflow evaluating associated type `T::This`
//[next]~^^ ERROR: type mismatch resolving `T::This normalizes-to _`
}

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
error[E0271]: type mismatch resolving `X3 normalizes-to _`
--> $DIR/infinite-type-alias-mutual-recursion.rs:12:1
|
LL | type X1 = X2;
| ^^^^^^^ types differ

error[E0271]: type mismatch resolving `X1 normalizes-to _`
--> $DIR/infinite-type-alias-mutual-recursion.rs:16:1
|
LL | type X2 = X3;
| ^^^^^^^ types differ

error[E0271]: type mismatch resolving `X2 normalizes-to _`
--> $DIR/infinite-type-alias-mutual-recursion.rs:19:1
|
LL | type X3 = X1;
| ^^^^^^^ types differ

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0271`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
error[E0275]: overflow normalizing the type alias `X2`
--> $DIR/infinite-type-alias-mutual-recursion.rs:12:1
|
LL | type X1 = X2;
| ^^^^^^^
|
= note: in case this is a recursive type alias, consider using a struct, enum, or union instead

error[E0275]: overflow normalizing the type alias `X3`
--> $DIR/infinite-type-alias-mutual-recursion.rs:16:1
|
LL | type X2 = X3;
| ^^^^^^^
|
= note: in case this is a recursive type alias, consider using a struct, enum, or union instead

error[E0275]: overflow normalizing the type alias `X1`
--> $DIR/infinite-type-alias-mutual-recursion.rs:19:1
|
LL | type X3 = X1;
| ^^^^^^^
|
= note: in case this is a recursive type alias, consider using a struct, enum, or union instead

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0275`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
error[E0391]: cycle detected when expanding type alias `X1`
--> $DIR/infinite-type-alias-mutual-recursion.rs:12:11
|
LL | type X1 = X2;
| ^^
|
note: ...which requires expanding type alias `X2`...
--> $DIR/infinite-type-alias-mutual-recursion.rs:16:11
|
LL | type X2 = X3;
| ^^
note: ...which requires expanding type alias `X3`...
--> $DIR/infinite-type-alias-mutual-recursion.rs:19:11
|
LL | type X3 = X1;
| ^^
= note: ...which again requires expanding type alias `X1`, completing the cycle
= note: type aliases cannot be recursive
= help: consider using a struct, enum, or union instead to break the cycle
= help: see <https://doc.rust-lang.org/reference/types.html#recursive-types> for more information
note: cycle used when checking that `X1` is well-formed
--> $DIR/infinite-type-alias-mutual-recursion.rs:12:1
|
LL | type X1 = X2;
| ^^^^^^^
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0391`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
error[E0391]: cycle detected when expanding type alias `X1`
--> $DIR/infinite-type-alias-mutual-recursion.rs:12:11
|
LL | type X1 = X2;
| ^^
|
note: ...which requires expanding type alias `X2`...
--> $DIR/infinite-type-alias-mutual-recursion.rs:16:11
|
LL | type X2 = X3;
| ^^
note: ...which requires expanding type alias `X3`...
--> $DIR/infinite-type-alias-mutual-recursion.rs:19:11
|
LL | type X3 = X1;
| ^^
= note: ...which again requires expanding type alias `X1`, completing the cycle
= note: type aliases cannot be recursive
= help: consider using a struct, enum, or union instead to break the cycle
= help: see <https://doc.rust-lang.org/reference/types.html#recursive-types> for more information
note: cycle used when checking that `X1` is well-formed
--> $DIR/infinite-type-alias-mutual-recursion.rs:12:1
|
LL | type X1 = X2;
| ^^^^^^^
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0391`.
21 changes: 15 additions & 6 deletions tests/ui/infinite/infinite-type-alias-mutual-recursion.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
//@ revisions: feature gated
//@ revisions: feature_old gated_old feature_new gated_new
//@ ignore-parallel-frontend query cycle
#![cfg_attr(feature, feature(lazy_type_alias))]
//@ ignore-compare-mode-next-solver (explicit revisions)
//@ [feature_new] compile-flags: -Znext-solver
//@ [gated_new] compile-flags: -Znext-solver

#![feature(rustc_attrs)]
#![rustc_no_implicit_bounds]
#![cfg_attr(any(feature_old, feature_new), feature(lazy_type_alias))]
#![allow(incomplete_features)]

type X1 = X2;
//[gated]~^ ERROR cycle detected when expanding type alias `X1`
//[feature]~^^ ERROR: overflow normalizing the type alias `X2`
//[gated_old,gated_new]~^ ERROR cycle detected when expanding type alias `X1`
//[feature_old]~^^ ERROR: overflow normalizing the type alias `X2`
//[feature_new]~^^^ ERROR: type mismatch resolving `X3 normalizes-to _`

@lqd lqd May 7, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a note of the slightly suboptimal diagnostics here compared to the old solver mentioning X1 or X2

View changes since the review

type X2 = X3;
//[feature]~^ ERROR: overflow normalizing the type alias `X3`
//[feature_old]~^ ERROR: overflow normalizing the type alias `X3`
//[feature_new]~^^ ERROR: type mismatch resolving `X1 normalizes-to _`
type X3 = X1;
//[feature]~^ ERROR: overflow normalizing the type alias `X1`
//[feature_old]~^ ERROR: overflow normalizing the type alias `X1`
//[feature_new]~^^ ERROR: type mismatch resolving `X2 normalizes-to _`

fn main() {}