-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Rust: Rework type inference for method calls #20282
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
base: main
Are you sure you want to change the base?
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 |
---|---|---|
|
@@ -636,6 +636,8 @@ final class ImplItemNode extends ImplOrTraitItemNode instanceof Impl { | |
|
||
TraitItemNode resolveTraitTy() { result = resolvePath(this.getTraitPath()) } | ||
|
||
predicate isBlanket() { this.resolveSelfTy() instanceof TypeParam } | ||
|
||
override AssocItemNode getAnAssocItem() { result = this.getADescendant() } | ||
|
||
override string getName() { result = "(impl)" } | ||
|
@@ -721,7 +723,7 @@ final class ImplItemNode extends ImplOrTraitItemNode instanceof Impl { | |
} | ||
} | ||
|
||
final private class ImplTraitTypeReprItemNode extends TypeItemNode instanceof ImplTraitTypeRepr { | ||
final class ImplTraitTypeReprItemNode extends TypeItemNode instanceof ImplTraitTypeRepr { | ||
pragma[nomagic] | ||
Path getABoundPath() { | ||
result = super.getTypeBoundList().getABound().getTypeRepr().(PathTypeRepr).getPath() | ||
|
@@ -1444,6 +1446,16 @@ module TraitIsVisible<relevantTraitVisibleSig/2 relevantTraitVisible> { | |
predicate traitIsVisible(Element element, Trait trait) { | ||
exists(ItemNode encl | traitLookup(encl, element, trait) and trait = encl.getASuccessor(_, _)) | ||
} | ||
|
||
/** Holds if the trait `trait` is _not_ visible at `element`. */ | ||
pragma[nomagic] | ||
predicate traitIsNotVisible(Element element, Trait trait) { | ||
exists(ItemNode top | | ||
traitLookup(top, element, trait) and | ||
not exists(getOuterScope(top)) and | ||
not trait = top.getASuccessor(_, _) | ||
) | ||
} | ||
} | ||
|
||
pragma[nomagic] | ||
|
@@ -1740,7 +1752,7 @@ private module Debug { | |
exists(string filepath, int startline, int startcolumn, int endline, int endcolumn | | ||
result.getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn) and | ||
filepath.matches("%/main.rs") and | ||
startline = 52 | ||
startline = 167 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nitpick] This hardcoded line number in the debug module should be removed or made configurable. Having hardcoded debug coordinates in production code can cause confusion and makes the code less maintainable. See below for a potential fix:
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||
) | ||
} | ||
|
||
|
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 hardcoded line number (167) in the debug module appears to be a leftover from development/testing. Consider removing this specific line constraint or making it configurable to avoid issues when the test file structure changes.
See below for a potential fix:
Copilot uses AI. Check for mistakes.