-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Fix for "ambiguous associated type" issue with ATBs #61919
Conversation
I'm not sure of the underlying motivation for the actual fix (2nd commit)... having diagnosed the problem, I addressed it very much "head on". If this is the right solution, then great. Either way, I should probably add a little explainer comment to the |
☔ The latest upstream changes (presumably #61983) made this pull request unmergeable. Please resolve the merge conflicts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I spent some more time looking into this PR this morning. I actually think this is the wrong approach. The problem seems to be this:
The functon type_param_predicates
in collect.rs is meant to return only the predicates that apply to the type parameter with the given def-id. i.e., if you have the defid for T
, it should return predicates like T: Foo
and T: Bar
. But today, if you have T: Foo<Bar: Baz>
, it is also returning <T as Foo>::Bar: Baz
. This then confuses the code in find_bound_for_assoc_item
in astconv.rs
down the line, which assumes that the self-type is always just T
. Threading this boolean flag works to suppress that confusion, but it's not my preferred approach.
I think what I would rather do is just add a filtering step right after this line, similar to what you find in the FnCtxt
code.
Also, I think we should add a comment to type_param_predicates
and get_type_parameter_bounds
clarifying that they take a type parameter and return only the predicates that apply to that. I might push a comment or two to that effect to your branch.
An alternative might be to add filtering around this line -- i.e., at the place where |
and hence you would want to adjust the comments accordingly |
Ping from triage, any updates? @alexreg |
@Alexendoo Yeah sorry, I meant to get around to this, but I will finally in the next day or two. |
Ping from triage. |
@JohnCSimon Ah sorry. Later today, I'm pretty confident! |
@nikomatsakis Tried your first approach, since that made perfect sense to me, while I didn't quite get your alternative one. Hope that's alright. @varkor Pending a rebase and adding a test for #61738, would you mind kindly reviewing this in Niko's absence? I think you know this part of the compiler reasonably well. |
src/test/ui/associated-type-bounds/ambiguous-associated-type.rs
Outdated
Show resolved
Hide resolved
@bors r+ |
📌 Commit 0410e32 has been approved by |
Fix for "ambiguous associated type" issue with ATBs Fixes #61752. r? @nikomatsakis CC @Centril
Thanks @nikomatsakis! |
☀️ Test successful - checks-azure |
Fixes #61752.
r? @nikomatsakis
CC @Centril