Repository navigation
add a few new solver normalization tests #156250
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
Changes from all commits
e2ea0ba
4922210
6cc6a63
130b1d8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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`. |
| 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`. |
| 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 _` | ||
| 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() {} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| // Ensure that defaulted type parameters whose default contains diverging aliases are properly | ||
| // caught with both solvers. This is currently not the case, and this is tracked in issue | ||
| // https://github.com/rust-lang/rust/issues/156271. | ||
| // MCVE from https://github.com/rust-lang/trait-system-refactor-initiative/issues/139#issuecomment-2704576249. | ||
|
|
||
| //@ revisions: current next | ||
| //@ check-pass | ||
| //@ known-bug: #156271 | ||
| //@ ignore-compare-mode-next-solver (explicit revisions) | ||
| //@ [next] compile-flags: -Znext-solver | ||
|
|
||
| #![feature(rustc_attrs)] | ||
| #![rustc_no_implicit_bounds] | ||
|
|
||
| trait Trait { | ||
| type Diverges<D: Trait>; | ||
| } | ||
|
|
||
| impl<T> Trait for T { | ||
| type Diverges<D: Trait> = D::Diverges<D>; | ||
| } | ||
|
|
||
| struct Bar<T = <u8 as Trait>::Diverges<u8>>(*mut T); | ||
|
|
||
| fn main() {} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| error[E0275]: overflow evaluating the requirement `<u8 as Trait>::Diverges<u8> == _` | ||
| --> $DIR/normalize-diverging-alias-in-struct.rs:21:12 | ||
| | | ||
| LL | field: Box<<u8 as Trait>::Diverges<u8>>, | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
|
||
| error: aborting due to 1 previous error | ||
|
|
||
| For more information about this error, try `rustc --explain E0275`. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| error[E0271]: type mismatch resolving `<u8 as Trait>::Diverges<u8> normalizes-to _` | ||
| --> $DIR/normalize-diverging-alias-in-struct.rs:21:12 | ||
| | | ||
| LL | field: Box<<u8 as Trait>::Diverges<u8>>, | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ types differ | ||
|
|
||
| error[E0271]: type mismatch resolving `<u8 as Trait>::Diverges<u8> normalizes-to _` | ||
| --> $DIR/normalize-diverging-alias-in-struct.rs:21:12 | ||
| | | ||
| LL | field: Box<<u8 as Trait>::Diverges<u8>>, | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ types differ | ||
| | | ||
| note: required by a bound in `Box` | ||
| --> $SRC_DIR/alloc/src/boxed.rs:LL:COL | ||
|
|
||
| error: aborting due to 2 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 @@ | ||
| // Ensure that structs with fields whose types contain diverging aliases are properly caught with | ||
| // both solvers. | ||
| // MCVE from https://github.com/rust-lang/trait-system-refactor-initiative/issues/139#issuecomment-2703127026. | ||
|
|
||
| //@ revisions: current next | ||
| //@ ignore-compare-mode-next-solver (explicit revisions) | ||
| //@ [next] compile-flags: -Znext-solver | ||
|
|
||
| #![feature(rustc_attrs)] | ||
| #![rustc_no_implicit_bounds] | ||
|
|
||
| trait Trait { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you also add
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. alright, I've added it for the tests modified/added/moved in this PR. |
||
| type Diverges<D: Trait>; | ||
| } | ||
|
|
||
| impl<T> Trait for T { | ||
| type Diverges<D: Trait> = D::Diverges<D>; | ||
| } | ||
|
|
||
| struct Foo { | ||
| field: Box<<u8 as Trait>::Diverges<u8>>, | ||
| //[current]~^ ERROR: overflow evaluating the requirement `<u8 as Trait>::Diverges<u8> == _` | ||
| //[next]~^^ ERROR: type mismatch resolving `<u8 as Trait>::Diverges<u8> normalizes-to _` | ||
| //[next]~| ERROR: type mismatch resolving `<u8 as Trait>::Diverges<u8> normalizes-to _` | ||
| } | ||
|
|
||
| fn main() {} | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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