forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#118914 - compiler-errors:eager-alias-relate…
…, r=lcnr Unconditionally register alias-relate in projection goal Follow-up to rust-lang#118725, which subtly broke closure signature inference on combinators like `Result::map` which I noticed in syn. Essentially, instead of using `eq` which will eagerly infer `?1 := <?2 as Trait>::Assoc`, we can directly emit an alias-relate goal, which will stay ambiguous for as long as `?2` is ambiguous. This also more closely models the conceptual framing that projects-to acts like an alias-relate when solving, and like a normalizes-to when in a param env. r? lcnr
- Loading branch information
Showing
6 changed files
with
71 additions
and
13 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
21 changes: 21 additions & 0 deletions
21
tests/ui/traits/next-solver/closure-signature-inference-2.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,21 @@ | ||
// compile-flags: -Znext-solver | ||
// check-pass | ||
|
||
fn map<T: Default, U, F: FnOnce(T) -> U>(f: F) { | ||
f(T::default()); | ||
} | ||
|
||
fn main() { | ||
map::<i32, _ /* ?U */, _ /* ?F */>(|x| x.to_string()); | ||
// PREVIOUSLY when confirming the `map` call, we register: | ||
// | ||
// (1.) ?F: FnOnce<(i32,)> | ||
// (2.) <?F as FnOnce<(i32,)>>::Output projects-to ?U | ||
// | ||
// While (1.) is ambiguous, (2.) immediately gets processed | ||
// and we infer `?U := <?F as FnOnce<(i32,)>>::Output`. | ||
// | ||
// Thus, the only pending obligation that remains is (1.). | ||
// Since it is a trait obligation, we don't use it to deduce | ||
// the closure signature, and we fail! | ||
} |
15 changes: 15 additions & 0 deletions
15
tests/ui/traits/next-solver/closure-signature-inference.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,15 @@ | ||
// compile-flags: -Znext-solver | ||
// check-pass | ||
|
||
struct A; | ||
impl A { | ||
fn hi(self) {} | ||
} | ||
|
||
fn hello() -> Result<(A,), ()> { | ||
Err(()) | ||
} | ||
|
||
fn main() { | ||
let x = hello().map(|(x,)| x.hi()); | ||
} |
14 changes: 12 additions & 2 deletions
14
tests/ui/traits/next-solver/generalize/generalize-proj-new-universe-index-2.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
File renamed without changes.
File renamed without changes.