Skip to content

Rust: Use hasImplementation in path resolution #19745

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 2 additions & 16 deletions rust/ql/lib/codeql/rust/internal/PathResolution.qll
Original file line number Diff line number Diff line change
Expand Up @@ -425,14 +425,7 @@ abstract private class AssocItemNode extends ItemNode, AssocItem {
private class ConstItemNode extends AssocItemNode instanceof Const {
override string getName() { result = Const.super.getName().getText() }

override predicate hasImplementation() {
super.hasBody()
or
// for trait items from library code, we do not currently know if they
// have default implementations or not, so we assume they do
not this.fromSource() and
this = any(TraitItemNode t).getAnAssocItem()
}
override predicate hasImplementation() { Const.super.hasImplementation() }

override Namespace getNamespace() { result.isValue() }

Expand Down Expand Up @@ -508,14 +501,7 @@ private class VariantItemNode extends ItemNode instanceof Variant {
class FunctionItemNode extends AssocItemNode instanceof Function {
override string getName() { result = Function.super.getName().getText() }

override predicate hasImplementation() {
super.hasBody()
or
// for trait items from library code, we do not currently know if they
// have default implementations or not, so we assume they do
not this.fromSource() and
this = any(TraitItemNode t).getAnAssocItem()
}
override predicate hasImplementation() { Function.super.hasImplementation() }

override Namespace getNamespace() { result.isValue() }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,3 @@ multiplePathResolutions
| deallocation.rs:261:11:261:22 | ...::from | file://:0:0:0:0 | fn from |
| deallocation.rs:261:11:261:22 | ...::from | file://:0:0:0:0 | fn from |
| deallocation.rs:261:11:261:22 | ...::from | file://:0:0:0:0 | fn from |
| lifetime.rs:415:32:415:49 | ...::clone | file://:0:0:0:0 | fn clone |
| lifetime.rs:415:32:415:49 | ...::clone | file://:0:0:0:0 | fn clone |