Add supertrait item shadowing for type-level path resolution#152225
Add supertrait item shadowing for type-level path resolution#152225Amanieu wants to merge 1 commit intorust-lang:mainfrom
Conversation
|
HIR ty lowering was modified cc @fmease |
|
r? @madsmtm rustbot has assigned @madsmtm. Use Why was this reviewer chosen?The reviewer was selected based on:
|
| println!("{}", size_of::<T::T>()); | ||
| } | ||
|
|
||
| fn generic2<T: C<T = i16>>() { |
There was a problem hiding this comment.
What about T: B<T = i16> and T: A<T = i8> - do those resolve to B::T and A::T respectively?
Also, please use a different name for the generic and the associated type, it's a bit confusing as-is.
There was a problem hiding this comment.
I've cleaned up the example and added tests showing how B<T = i16> and A<T = i8> are resolved.
|
r? types |
Wait, I'm not sure if that should've unassigned me or not? In any case, if you also need a compiler reviewer, I'm the wrong one for the job, so I'm gonna unassign myself. |
1cde4c7 to
5a9ef14
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. |
This makes type-level name resolution (used primarily for associated types) also prefer subtrait items to supertrait items in case of ambiguity.
This addresses the concern from #148605 about the inconsistency with name resolution in expressions and method calls.