mirror of
https://github.com/github/codeql.git
synced 2026-04-20 22:44:52 +02:00
Rust: Fix bug in path resolution library
This commit is contained in:
@@ -284,7 +284,7 @@ abstract class ImplOrTraitItemNode extends ItemNode {
|
||||
/** Gets a `Self` path that refers to this item. */
|
||||
Path getASelfPath() {
|
||||
isUnqualifiedSelfPath(result) and
|
||||
this = unqualifiedPathLookup(result)
|
||||
this = unqualifiedPathLookup(result, _)
|
||||
}
|
||||
|
||||
/** Gets an associated item belonging to this trait or `impl` block. */
|
||||
@@ -680,8 +680,8 @@ private ItemNode getASuccessor(ItemNode pred, string name, Namespace ns) {
|
||||
}
|
||||
|
||||
pragma[nomagic]
|
||||
private ItemNode unqualifiedPathLookup(RelevantPath path) {
|
||||
exists(ItemNode encl, Namespace ns, string name |
|
||||
private ItemNode unqualifiedPathLookup(RelevantPath path, Namespace ns) {
|
||||
exists(ItemNode encl, string name |
|
||||
unqualifiedPathLookup(path, name, ns, encl) and
|
||||
result = getASuccessor(encl, name, ns)
|
||||
)
|
||||
@@ -691,9 +691,9 @@ pragma[nomagic]
|
||||
private predicate isUnqualifiedSelfPath(RelevantPath path) { path.isUnqualified("Self") }
|
||||
|
||||
pragma[nomagic]
|
||||
private ItemNode resolvePath0(RelevantPath path) {
|
||||
private ItemNode resolvePath0(RelevantPath path, Namespace ns) {
|
||||
exists(ItemNode res |
|
||||
res = unqualifiedPathLookup(path) and
|
||||
res = unqualifiedPathLookup(path, ns) and
|
||||
if
|
||||
not any(RelevantPath parent).getQualifier() = path and
|
||||
isUnqualifiedSelfPath(path) and
|
||||
@@ -704,10 +704,12 @@ private ItemNode resolvePath0(RelevantPath path) {
|
||||
or
|
||||
exists(ItemNode q, string name |
|
||||
q = resolvePathQualifier(path, name) and
|
||||
result = q.getASuccessor(name)
|
||||
result = q.getASuccessor(name) and
|
||||
ns = result.getNamespace()
|
||||
)
|
||||
or
|
||||
result = resolveUseTreeListItem(_, _, path)
|
||||
result = resolveUseTreeListItem(_, _, path) and
|
||||
ns = result.getNamespace()
|
||||
}
|
||||
|
||||
/** Holds if path `p` must be looked up in namespace `n`. */
|
||||
@@ -743,9 +745,8 @@ private predicate pathUsesNamespace(Path p, Namespace n) {
|
||||
/** Gets the item that `path` resolves to, if any. */
|
||||
cached
|
||||
ItemNode resolvePath(RelevantPath path) {
|
||||
result = resolvePath0(path) and
|
||||
(
|
||||
pathUsesNamespace(path, result.getNamespace())
|
||||
exists(Namespace ns | result = resolvePath0(path, ns) |
|
||||
pathUsesNamespace(path, ns)
|
||||
or
|
||||
not pathUsesNamespace(path, _)
|
||||
)
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
multiplePathResolutions
|
||||
| main.rs:385:34:385:34 | S | main.rs:384:19:384:19 | S |
|
||||
| main.rs:385:34:385:34 | S | main.rs:411:5:412:13 | struct S |
|
||||
| main.rs:387:39:387:39 | S | main.rs:384:19:384:19 | S |
|
||||
| main.rs:387:39:387:39 | S | main.rs:411:5:412:13 | struct S |
|
||||
@@ -424,19 +424,14 @@ resolveType
|
||||
| main.rs:385:16:385:24 | SelfParam | &T | main.rs:384:5:390:5 | trait MyTrait |
|
||||
| main.rs:385:16:385:24 | SelfParam | &T.S | main.rs:384:19:384:19 | S |
|
||||
| main.rs:385:27:385:31 | value | | main.rs:384:19:384:19 | S |
|
||||
| main.rs:385:27:385:31 | value | | main.rs:411:5:412:13 | struct S |
|
||||
| main.rs:387:21:387:29 | SelfParam | | file://:0:0:0:0 | & |
|
||||
| main.rs:387:21:387:29 | SelfParam | &T | main.rs:384:5:390:5 | trait MyTrait |
|
||||
| main.rs:387:21:387:29 | SelfParam | &T.S | main.rs:384:19:384:19 | S |
|
||||
| main.rs:387:21:387:29 | SelfParam | &T.S | main.rs:411:5:412:13 | struct S |
|
||||
| main.rs:387:32:387:36 | value | | main.rs:384:19:384:19 | S |
|
||||
| main.rs:387:32:387:36 | value | | main.rs:411:5:412:13 | struct S |
|
||||
| main.rs:388:13:388:16 | self | | file://:0:0:0:0 | & |
|
||||
| main.rs:388:13:388:16 | self | &T | main.rs:384:5:390:5 | trait MyTrait |
|
||||
| main.rs:388:13:388:16 | self | &T.S | main.rs:384:19:384:19 | S |
|
||||
| main.rs:388:13:388:16 | self | &T.S | main.rs:411:5:412:13 | struct S |
|
||||
| main.rs:388:22:388:26 | value | | main.rs:384:19:384:19 | S |
|
||||
| main.rs:388:22:388:26 | value | | main.rs:411:5:412:13 | struct S |
|
||||
| main.rs:393:16:393:24 | SelfParam | | file://:0:0:0:0 | & |
|
||||
| main.rs:393:16:393:24 | SelfParam | &T | main.rs:378:5:382:5 | enum MyOption |
|
||||
| main.rs:393:16:393:24 | SelfParam | &T.T | main.rs:392:10:392:10 | T |
|
||||
|
||||
Reference in New Issue
Block a user