-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Use structurally_normalize
instead of manual normalizes-to
goals in alias relate errors
#135816
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
+267
−121
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
...ync-await/async-closures/is-not-fn.stderr → ...t/async-closures/is-not-fn.current.stderr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
error[E0271]: expected `{async [email protected]:5:14}` to be a closure that returns `()`, but it returns `{async closure body@$DIR/is-not-fn.rs:5:23: 5:25}` | ||
--> $DIR/is-not-fn.rs:5:14 | ||
error[E0271]: expected `{async [email protected]:8:14}` to be a closure that returns `()`, but it returns `{async closure body@$DIR/is-not-fn.rs:8:23: 8:25}` | ||
--> $DIR/is-not-fn.rs:8:14 | ||
| | ||
LL | needs_fn(async || {}); | ||
| -------- ^^^^^^^^^^^ expected `()`, found `async` closure body | ||
| | | ||
| required by a bound introduced by this call | ||
| | ||
= note: expected unit type `()` | ||
found `async` closure body `{async closure body@$DIR/is-not-fn.rs:5:23: 5:25}` | ||
found `async` closure body `{async closure body@$DIR/is-not-fn.rs:8:23: 8:25}` | ||
note: required by a bound in `needs_fn` | ||
--> $DIR/is-not-fn.rs:4:25 | ||
--> $DIR/is-not-fn.rs:7:25 | ||
| | ||
LL | fn needs_fn(x: impl FnOnce()) {} | ||
| ^^^^^^^^ required by this bound in `needs_fn` | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
error[E0271]: expected `{async [email protected]:8:14}` to be a closure that returns `()`, but it returns `{async closure body@$DIR/is-not-fn.rs:8:23: 8:25}` | ||
--> $DIR/is-not-fn.rs:8:14 | ||
| | ||
LL | needs_fn(async || {}); | ||
| -------- ^^^^^^^^^^^ expected `()`, found `async` closure body | ||
| | | ||
| required by a bound introduced by this call | ||
| | ||
= note: expected unit type `()` | ||
found `async` closure body `{async closure body@$DIR/is-not-fn.rs:8:23: 8:25}` | ||
note: required by a bound in `needs_fn` | ||
--> $DIR/is-not-fn.rs:7:25 | ||
| | ||
LL | fn needs_fn(x: impl FnOnce()) {} | ||
| ^^^^^^^^ required by this bound in `needs_fn` | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0271`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
//@ edition:2021 | ||
//@ revisions: current next | ||
//@ ignore-compare-mode-next-solver (explicit revisions) | ||
//@[next] compile-flags: -Znext-solver | ||
|
||
fn main() { | ||
fn needs_fn(x: impl FnOnce()) {} | ||
needs_fn(async || {}); | ||
//~^ ERROR expected `{async [email protected]:5:14}` to be a closure that returns `()` | ||
//~^ ERROR expected `{async [email protected]:8:14}` to be a closure that returns `()` | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
tests/ui/impl-trait/ice-unexpected-param-type-whensubstituting-in-region-112823.next.stderr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
error[E0407]: method `line_stream` is not a member of trait `X` | ||
--> $DIR/ice-unexpected-param-type-whensubstituting-in-region-112823.rs:28:5 | ||
| | ||
LL | fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr> {} | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a member of trait `X` | ||
|
||
error[E0049]: type `LineStream` has 0 type parameters but its trait declaration has 1 type parameter | ||
--> $DIR/ice-unexpected-param-type-whensubstituting-in-region-112823.rs:25:21 | ||
| | ||
LL | type LineStream<'a, Repr> | ||
| -- ---- | ||
| | | ||
| expected 1 type parameter | ||
... | ||
LL | type LineStream<'c, 'd> = impl Stream; | ||
| ^^ ^^ | ||
| | | ||
| found 0 type parameters | ||
|
||
error[E0271]: type mismatch resolving `<Y as X>::LineStreamFut<'a, Repr> == ()` | ||
--> $DIR/ice-unexpected-param-type-whensubstituting-in-region-112823.rs:28:43 | ||
| | ||
LL | fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr> {} | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ types differ | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
Some errors have detailed explanations: E0049, E0271, E0407. | ||
For more information about an error, try `rustc --explain E0049`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
error[E0271]: expected `Iter<'_, _, _>` to be an iterator that yields `&_`, but it yields `(&_, &_)` | ||
--> $DIR/issue-33941.rs:9:36 | ||
| | ||
LL | for _ in HashMap::new().iter().cloned() {} | ||
| ^^^^^^ expected `&_`, found `(&_, &_)` | ||
| | ||
= note: expected reference `&_` | ||
found tuple `(&_, &_)` | ||
note: required by a bound in `cloned` | ||
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL | ||
|
||
error[E0271]: expected `Iter<'_, _, _>` to be an iterator that yields `&_`, but it yields `(&_, &_)` | ||
--> $DIR/issue-33941.rs:9:14 | ||
| | ||
LL | for _ in HashMap::new().iter().cloned() {} | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&_`, found `(&_, &_)` | ||
| | ||
= note: expected reference `&_` | ||
found tuple `(&_, &_)` | ||
= note: required for `Cloned<std::collections::hash_map::Iter<'_, _, _>>` to implement `Iterator` | ||
= note: required for `Cloned<std::collections::hash_map::Iter<'_, _, _>>` to implement `IntoIterator` | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0271`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
//@ revisions: current next | ||
//@ ignore-compare-mode-next-solver (explicit revisions) | ||
//@[next] compile-flags: -Znext-solver | ||
//@ compile-flags: -Zdeduplicate-diagnostics=yes | ||
|
||
use std::collections::HashMap; | ||
|
||
fn main() { | ||
for _ in HashMap::new().iter().cloned() {} //~ ERROR expected `Iter<'_, _, _>` to be an iterator that yields `&_`, but it yields `(&_, &_)` | ||
for _ in HashMap::new().iter().cloned() {} | ||
//~^ ERROR expected `Iter<'_, _, _>` to be an iterator that yields `&_`, but it yields `(&_, &_)` | ||
//~| ERROR expected `Iter<'_, _, _>` to be an iterator that yields `&_`, but it yields `(&_, &_)` | ||
} |
12 changes: 12 additions & 0 deletions
12
tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.current.fixed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
//@ revisions: current next | ||
//@ ignore-compare-mode-next-solver (explicit revisions) | ||
//@[next] compile-flags: -Znext-solver | ||
//@[current] run-rustfix | ||
fn main() { | ||
let _ = (-10..=10).find(|x: &i32| x.signum() == 0); | ||
//[current]~^ ERROR type mismatch in closure arguments | ||
//[next]~^^ ERROR expected a `FnMut(&<RangeInclusive<{integer}> as Iterator>::Item)` closure, found | ||
let _ = (-10..=10).find(|x: &i32| x.signum() == 0); | ||
//[current]~^ ERROR type mismatch in closure arguments | ||
//[next]~^^ ERROR expected `RangeInclusive<{integer}>` to be an iterator that yields `&&i32`, but it yields `{integer}` | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 0 additions & 5 deletions
5
tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.fixed
This file was deleted.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.next.stderr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
error[E0277]: expected a `FnMut(&<RangeInclusive<{integer}> as Iterator>::Item)` closure, found `{closure@$DIR/closure-arg-type-mismatch-issue-45727.rs:6:29: 6:37}` | ||
--> $DIR/closure-arg-type-mismatch-issue-45727.rs:6:29 | ||
| | ||
LL | let _ = (-10..=10).find(|x: i32| x.signum() == 0); | ||
| ---- ^^^^^^^^^^^^^^^^^^^^^^^^ expected an `FnMut(&<RangeInclusive<{integer}> as Iterator>::Item)` closure, found `{closure@$DIR/closure-arg-type-mismatch-issue-45727.rs:6:29: 6:37}` | ||
| | | ||
| required by a bound introduced by this call | ||
| | ||
= help: the trait `for<'a> FnMut(&'a <RangeInclusive<{integer}> as Iterator>::Item)` is not implemented for closure `{closure@$DIR/closure-arg-type-mismatch-issue-45727.rs:6:29: 6:37}` | ||
= note: expected a closure with arguments `(i32,)` | ||
found a closure with arguments `(&<RangeInclusive<{integer}> as Iterator>::Item,)` | ||
note: required by a bound in `find` | ||
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL | ||
|
||
error[E0271]: expected `RangeInclusive<{integer}>` to be an iterator that yields `&&i32`, but it yields `{integer}` | ||
--> $DIR/closure-arg-type-mismatch-issue-45727.rs:9:33 | ||
| | ||
LL | let _ = (-10..=10).find(|x: &&&i32| x.signum() == 0); | ||
| ^^^^^^ expected `&&i32`, found integer | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
Some errors have detailed explanations: E0271, E0277. | ||
For more information about an error, try `rustc --explain E0271`. |
13 changes: 10 additions & 3 deletions
13
tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,12 @@ | ||
//@ run-rustfix | ||
//@ revisions: current next | ||
//@ ignore-compare-mode-next-solver (explicit revisions) | ||
//@[next] compile-flags: -Znext-solver | ||
//@[current] run-rustfix | ||
fn main() { | ||
let _ = (-10..=10).find(|x: i32| x.signum() == 0); //~ ERROR type mismatch in closure arguments | ||
let _ = (-10..=10).find(|x: &&&i32| x.signum() == 0); //~ ERROR type mismatch in closure arguments | ||
let _ = (-10..=10).find(|x: i32| x.signum() == 0); | ||
//[current]~^ ERROR type mismatch in closure arguments | ||
//[next]~^^ ERROR expected a `FnMut(&<RangeInclusive<{integer}> as Iterator>::Item)` closure, found | ||
let _ = (-10..=10).find(|x: &&&i32| x.signum() == 0); | ||
//[current]~^ ERROR type mismatch in closure arguments | ||
//[next]~^^ ERROR expected `RangeInclusive<{integer}>` to be an iterator that yields `&&i32`, but it yields `{integer}` | ||
} |
28 changes: 28 additions & 0 deletions
28
tests/ui/traits/next-solver/diagnostics/alias_relate_error_uses_structurally_normalize.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
//@ compile-flags: -Znext-solver | ||
|
||
// When encountering a fulfillment error from an `alias-relate` goal failing, we | ||
// would previously manually construct a `normalizes-to` goal involving the alias | ||
// and an infer var. This would then ICE as normalization would return a nested | ||
// goal (the `T: Sized` from the `Trait` impl for `Foo<T>` below) from the root goal | ||
// which is not supported. | ||
|
||
struct Foo<T>(T); | ||
|
||
trait Trait { | ||
type Assoc; | ||
} | ||
|
||
// `T: Sized` being explicit is not required, but the bound being present *is*. | ||
impl<T: Sized> Trait for Foo<T> { | ||
type Assoc = u64; | ||
} | ||
|
||
fn bar<T: Trait<Assoc = u32>>(_: T) {} | ||
|
||
fn main() { | ||
let foo = Foo(Default::default()); | ||
bar(foo); | ||
//~^ ERROR: type mismatch resolving `<Foo<_> as Trait>::Assoc == u32` | ||
// Here diagnostics would manually construct a `<Foo<?y> as Trait>::Assoc normalizes-to ?x` goal | ||
// which would return a nested goal of `?y: Sized` from the impl. | ||
} |
17 changes: 17 additions & 0 deletions
17
...s/ui/traits/next-solver/diagnostics/alias_relate_error_uses_structurally_normalize.stderr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
error[E0271]: type mismatch resolving `<Foo<_> as Trait>::Assoc == u32` | ||
--> $DIR/alias_relate_error_uses_structurally_normalize.rs:24:9 | ||
| | ||
LL | bar(foo); | ||
| --- ^^^ expected `u32`, found `u64` | ||
| | | ||
| required by a bound introduced by this call | ||
| | ||
note: required by a bound in `bar` | ||
--> $DIR/alias_relate_error_uses_structurally_normalize.rs:20:17 | ||
| | ||
LL | fn bar<T: Trait<Assoc = u32>>(_: T) {} | ||
| ^^^^^^^^^^^ required by this bound in `bar` | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0271`. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.