-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #119849 - lcnr:eagerly-instantiate-binders, r=compiler-…
…errors more eagerly instantiate binders The old solver sometimes incorrectly used `sub`, change it to explicitly instantiate binders and use `eq` instead. While doing so I also moved the instantiation before the normalize calls. This caused some observable changes, will explain these inline. This PR therefore requires a crater run and an FCP. r? types
- Loading branch information
Showing
56 changed files
with
513 additions
and
397 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 @@ | ||
//@ check-pass | ||
|
||
// We try to prove `T::Rigid: Into<?0>` and have 2 candidates from where-clauses: | ||
// | ||
// - `Into<String>` | ||
// - `Into<<T::Rigid as Elaborate>::Assoc>` | ||
// | ||
// This causes ambiguity unless we normalize the alias in the second candidate | ||
// to detect that they actually result in the same constraints. | ||
trait Trait { | ||
type Rigid: Elaborate<Assoc = String> + Into<String>; | ||
} | ||
|
||
trait Elaborate: Into<Self::Assoc> { | ||
type Assoc; | ||
} | ||
|
||
fn impls<T: Into<U>, U>(_: T) {} | ||
|
||
fn test<P: Trait>(rigid: P::Rigid) { | ||
impls(rigid); | ||
} | ||
|
||
fn main() {} |
27 changes: 27 additions & 0 deletions
27
tests/ui/associated-type-bounds/dedup-normalized-2-higher-ranked.rs
This file contains 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,27 @@ | ||
// We try to prove `for<'b> T::Rigid: Bound<'b, ?0>` and have 2 candidates from where-clauses: | ||
// | ||
// - `for<'a> Bound<'a, String>` | ||
// - `for<'a> Bound<'a, <T::Rigid as Elaborate>::Assoc>` | ||
// | ||
// This causes ambiguity unless we normalize the alias in the second candidate | ||
// to detect that they actually result in the same constraints. We currently | ||
// fail to detect that the constraints from these bounds are equal and error | ||
// with ambiguity. | ||
trait Bound<'a, U> {} | ||
|
||
trait Trait { | ||
type Rigid: Elaborate<Assoc = String> + for<'a> Bound<'a, String>; | ||
} | ||
|
||
trait Elaborate: for<'a> Bound<'a, Self::Assoc> { | ||
type Assoc; | ||
} | ||
|
||
fn impls<T: for<'b> Bound<'b, U>, U>(_: T) {} | ||
|
||
fn test<P: Trait>(rigid: P::Rigid) { | ||
impls(rigid); | ||
//~^ ERROR type annotations needed | ||
} | ||
|
||
fn main() {} |
20 changes: 20 additions & 0 deletions
20
tests/ui/associated-type-bounds/dedup-normalized-2-higher-ranked.stderr
This file contains 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,20 @@ | ||
error[E0283]: type annotations needed | ||
--> $DIR/dedup-normalized-2-higher-ranked.rs:23:5 | ||
| | ||
LL | impls(rigid); | ||
| ^^^^^ cannot infer type of the type parameter `U` declared on the function `impls` | ||
| | ||
= note: cannot satisfy `for<'b> <P as Trait>::Rigid: Bound<'b, _>` | ||
note: required by a bound in `impls` | ||
--> $DIR/dedup-normalized-2-higher-ranked.rs:20:13 | ||
| | ||
LL | fn impls<T: for<'b> Bound<'b, U>, U>(_: T) {} | ||
| ^^^^^^^^^^^^^^^^^^^^ required by this bound in `impls` | ||
help: consider specifying the generic arguments | ||
| | ||
LL | impls::<<P as Trait>::Rigid, U>(rigid); | ||
| ++++++++++++++++++++++++++ | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0283`. |
This file contains 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
Oops, something went wrong.