Fix inference for projections with associated traits with multiple bounds; fixes #34792#34912
Fix inference for projections with associated traits with multiple bounds; fixes #34792#34912rozbb wants to merge 1 commit intorust-lang:masterfrom
Conversation
|
r? @pnkfelix (rust_highfive has picked a reviewer for you, use r? to override) |
|
r? @eddyb |
|
I recall someone saying that this might require a crater test. Is that still the case? |
|
@doomrobo Indeed, although you first need to fix the two |
src/librustc/traits/select.rs
Outdated
There was a problem hiding this comment.
This doesn't need to be a probe, I believe in_snapshot will do.
|
Hmm. It appears that the error messages for Here is the gist for the first one. The second differs in the same way. I have no intuitions so far, but I'm looking into it. |
|
cc @nikomatsakis @jonathandturner What could cause those errors? It looks like the |
|
☔ The latest upstream changes (presumably #35091) made this pull request unmergeable. Please resolve the merge conflicts. |
|
Closing due to inactivity, but feel free to resubmit with a rebase! |
The problem was due to the fact that no particular trait bound was specified when a projection was matched with a trait bound, even when multiple bounds existed. The compiler consistently picked the first bound on the associated type that it found that was able to match the type's obligation (which, in the regression test, is
<F as Foo>or<Self as Foo>).The fix involved modifying the
SelectionCandidate::ProjectionCandidatevariant to carry a trait ref to refer to its matching bound. And instead of stopping on the first match we find, we add all matching bounds to thecandidatesvector. Also in the winnowing step, aProjectionCandidatecannot trump anotherProjectionCandidateunless they are identical.