Skip to content

Commit 87770c5

Browse files
committed
Rust: Exclude macro call paths from resolvePath
Path resolution only models values and types, so it doesn't make sense to resolve paths that are macro calls.
1 parent 2b89f12 commit 87770c5

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,8 @@ ItemNode resolvePath(RelevantPath path) {
830830
exists(Namespace ns | result = resolvePath0(path, ns) |
831831
pathUsesNamespace(path, ns)
832832
or
833-
not pathUsesNamespace(path, _)
833+
not pathUsesNamespace(path, _) and
834+
not path = any(MacroCall mc).getPath()
834835
)
835836
}
836837

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ private import PathResolution
77

88
/** Holds if `p` may resolve to multiple items including `i`. */
99
query predicate multiplePathResolutions(Path p, ItemNode i) {
10+
p.fromSource() and
1011
i = resolvePath(p) and
1112
// `use foo::bar` may use both a type `bar` and a value `bar`
1213
not p =

0 commit comments

Comments
 (0)