Skip to content

Commit ff4d414

Browse files
committed
Rust: Avoid overlapping path resolution consistency checks
1 parent cdd6245 commit ff4d414

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

rust/ql/consistency-queries/PathResolutionConsistency.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ class SourceLocatable extends Locatable {
2020
}
2121
}
2222

23-
query predicate multipleMethodCallTargets(SourceLocatable a, SourceLocatable b) {
24-
PathResolutionConsistency::multipleMethodCallTargets(a, b)
23+
query predicate multipleCallTargets(SourceLocatable a, SourceLocatable b) {
24+
PathResolutionConsistency::multipleCallTargets(a, b)
2525
}
2626

2727
query predicate multiplePathResolutions(SourceLocatable a, SourceLocatable b) {

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ query predicate multiplePathResolutions(Path p, ItemNode i) {
1717
not use.isGlob() and
1818
not use.hasUseTreeList()
1919
).getPath() and
20+
// avoid overlap with `multipleCallTargets` below
21+
not p = any(CallExpr ce).getFunction().(PathExpr).getPath() and
2022
strictcount(resolvePath(p)) > 1
2123
}
2224

2325
/** Holds if `call` has multiple static call targets including `target`. */
24-
query predicate multipleMethodCallTargets(MethodCallExpr call, Callable target) {
26+
query predicate multipleCallTargets(CallExprBase call, Callable target) {
2527
target = call.getStaticTarget() and
2628
strictcount(call.getStaticTarget()) > 1
2729
}
@@ -51,8 +53,8 @@ int getPathResolutionInconsistencyCounts(string type) {
5153
type = "Multiple path resolutions" and
5254
result = count(Path p | multiplePathResolutions(p, _) | p)
5355
or
54-
type = "Multiple static method call targets" and
55-
result = count(CallExprBase call | multipleMethodCallTargets(call, _) | call)
56+
type = "Multiple static call targets" and
57+
result = count(CallExprBase call | multipleCallTargets(call, _) | call)
5658
or
5759
type = "Multiple record fields" and
5860
result = count(FieldExpr fe | multipleStructFields(fe, _) | fe)

0 commit comments

Comments
 (0)