-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Normalize associated types in paths in expressions #14436
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
Normalize associated types in paths in expressions #14436
Conversation
// to a projection, which `TyLoweringContext` cannot handle on its own. | ||
while !remaining_segments.is_empty() { | ||
let resolved_segment = path.segments().get(remaining_idx - 1).unwrap(); | ||
let current_segment = remaining_segments.take(1); |
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.
There are a bunch of unwrap
in this function, which I think it is possible to remove by defining some windows like thing for PathSegments
(or by using Itertools::tuple_windows
) and a function which goes from a &PathSegment
to a &PathSegments
(similar to slice::from_ref
).
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.
we've got these path segment unwraps in more places (our API for paths isn't really that great currently)
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.
Okay, so we can do it in a follow up.
@bors r+ |
☀️ Test successful - checks-actions |
Part of #14393
When we resolve paths in expressions (either path expressions or paths in struct expressions), there's a need of projection normalization, which
TyLoweringContext
cannot do on its own. We've been properly applying normalization for paths in struct expressions without type anchor, but not for others:With this PR we correctly resolve the whole path, but we need some more tweaks in HIR and/or IDE layers to properly resolve a qualifier (prefix) of such paths and provide IDE features that are pointed out in #14393 to be currently broken.