Skip to content

Commit 1acd636

Browse files
authored
Merge pull request #19745 from hvitved/rust/path-resolution-has-implementation
Rust: Use `hasImplementation` in path resolution
2 parents 55eb9fb + 3d18e3e commit 1acd636

File tree

2 files changed

+2
-18
lines changed

2 files changed

+2
-18
lines changed

rust/ql/lib/codeql/rust/internal/PathResolution.qll

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -425,14 +425,7 @@ abstract private class AssocItemNode extends ItemNode, AssocItem {
425425
private class ConstItemNode extends AssocItemNode instanceof Const {
426426
override string getName() { result = Const.super.getName().getText() }
427427

428-
override predicate hasImplementation() {
429-
super.hasBody()
430-
or
431-
// for trait items from library code, we do not currently know if they
432-
// have default implementations or not, so we assume they do
433-
not this.fromSource() and
434-
this = any(TraitItemNode t).getAnAssocItem()
435-
}
428+
override predicate hasImplementation() { Const.super.hasImplementation() }
436429

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

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

511-
override predicate hasImplementation() {
512-
super.hasBody()
513-
or
514-
// for trait items from library code, we do not currently know if they
515-
// have default implementations or not, so we assume they do
516-
not this.fromSource() and
517-
this = any(TraitItemNode t).getAnAssocItem()
518-
}
504+
override predicate hasImplementation() { Function.super.hasImplementation() }
519505

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

rust/ql/test/query-tests/security/CWE-825/CONSISTENCY/PathResolutionConsistency.expected

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,3 @@ multiplePathResolutions
2121
| deallocation.rs:261:11:261:22 | ...::from | file://:0:0:0:0 | fn from |
2222
| deallocation.rs:261:11:261:22 | ...::from | file://:0:0:0:0 | fn from |
2323
| deallocation.rs:261:11:261:22 | ...::from | file://:0:0:0:0 | fn from |
24-
| lifetime.rs:415:32:415:49 | ...::clone | file://:0:0:0:0 | fn clone |
25-
| lifetime.rs:415:32:415:49 | ...::clone | file://:0:0:0:0 | fn clone |

0 commit comments

Comments
 (0)