Avoid inference constraints from opaque blanket impls - #160752
Conversation
|
r? @nnethercote rustbot has assigned @nnethercote. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
r? @lcnr |
This comment has been minimized.
This comment has been minimized.
| // Blanket impls here only guide inference while the opaque hidden type | ||
| // is unknown. Do not let constraints from matching the impl itself | ||
| // constrain other inference variables. | ||
| Ok(ecx.make_ambiguous_response_no_constraints(maybe)) |
There was a problem hiding this comment.
that would also cause undesirable breakage, e.g I would like to use blanket impls for <impl Iterator<Item = u32> as IntoIterator>::Item. You should be able to construct a complete example from that by looking at the original PR/issue adding this hack for opaque types. I think that currently breaks with your PR
There was a problem hiding this comment.
now only reject the blanket impl if matching the impl itself constrains another trait argument and still allowing inference from the opaque bounds
|
@rustbot author |
|
Reminder, once the PR becomes ready for a review, use |
Signed-off-by: Amirhossein Akhlaghpour <m9.akhlaghpoor@gmail.com>
876b69c to
530b635
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
@rustbot ready |
| .args | ||
| .iter() | ||
| .skip(1) | ||
| .all(|arg| ecx.resolve_vars_if_possible(arg) == arg) |
There was a problem hiding this comment.
hmm, also feeling unsure about that you could imagine
?opaque = impl Trait<Assoc = u32>
?opaque: OtherTrait<?u>
impl<T: Trait<Assoc = U>, U> OtherTrait<U> for T {}sorry for not having much capacity to review this PR
There was a problem hiding this comment.
actually i was working on this pr meanwhile and yeah, that case works with the current check. I added it
Signed-off-by: Amirhossein Akhlaghpour <m9.akhlaghpoor@gmail.com>
Fixes rust-lang/trait-system-refactor-initiative#229
It's avoid constraining other inference variables when using blanket impls for unresolved opaque types while still keeping useful inference from opaque bounds and only rejects the blanket impl when matching the impl itself constrains another trait argument