-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Rust: Path resolution improvements #20453
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -72,9 +72,9 @@ private ItemNode getAChildSuccessor(ItemNode item, string name, SuccessorKind ki | |||||||||||
| if item instanceof ImplOrTraitItemNode and result instanceof AssocItem | ||||||||||||
| then kind.isExternal() | ||||||||||||
| else | ||||||||||||
| if result instanceof Use | ||||||||||||
| then kind.isInternal() | ||||||||||||
| else kind.isBoth() | ||||||||||||
| if result.isPublic() | ||||||||||||
| then kind.isBoth() | ||||||||||||
| else kind.isInternal() | ||||||||||||
| ) | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
|
|
@@ -165,6 +165,20 @@ abstract class ItemNode extends Locatable { | |||||||||||
| /** Gets the visibility of this item, if any. */ | ||||||||||||
| abstract Visibility getVisibility(); | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
| * Holds if this item is public. | ||||||||||||
| * | ||||||||||||
| * This is the case when this item either has `pub` visibility (but is not | ||||||||||||
| * a `use`; a `use` itself is not visible from the outside), or when this | ||||||||||||
| * item is a variant. | ||||||||||||
| */ | ||||||||||||
| predicate isPublic() { | ||||||||||||
| exists(this.getVisibility()) and | ||||||||||||
| not this instanceof Use | ||||||||||||
| or | ||||||||||||
| this instanceof Variant | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| /** Gets the `i`th type parameter of this item, if any. */ | ||||||||||||
| abstract TypeParam getTypeParam(int i); | ||||||||||||
|
|
||||||||||||
|
|
@@ -380,9 +394,7 @@ abstract private class ModuleLikeNode extends ItemNode { | |||||||||||
|
|
||||||||||||
| private class SourceFileItemNode extends ModuleLikeNode, SourceFile { | ||||||||||||
| pragma[nomagic] | ||||||||||||
| ModuleLikeNode getSuper() { | ||||||||||||
| result = any(ModuleItemNode mod | fileImport(mod, this)).getASuccessor("super") | ||||||||||||
| } | ||||||||||||
| ModuleLikeNode getSuper() { fileImport(result.getAnItemInScope(), this) } | ||||||||||||
|
||||||||||||
| ModuleLikeNode getSuper() { fileImport(result.getAnItemInScope(), this) } | |
| ModuleLikeNode getSuper() { any(ModuleItemNode mod | fileImport(mod, this)).getASuccessor("super") } |
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.
This line is just because the case we're handling here never overlaps with type parameters?
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.
It is to avoid the case that you originally fixed in #20096.
Copilot
AI
Sep 19, 2025
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.
This logic assumes that when pathName is not "self", the path text should be used as the import name. However, for qualified paths like foo::bar::baz, this would use "baz" as the name, but the original logic used item.getName() which might be different if the item was already renamed in an intermediate import.
| exists(string pathName | | |
| pathName = tree.getPath().getText() and | |
| if pathName = "self" then name = item.getName() else name = pathName | |
| ) | |
| name = item.getName() |
Uh oh!
There was an error while loading. Please reload this page.