Skip to content

Commit d370452

Browse files
committed
Rust: Remove source vs library deduplication logic
1 parent e33ddce commit d370452

File tree

1 file changed

+10
-36
lines changed

1 file changed

+10
-36
lines changed

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

Lines changed: 10 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -561,17 +561,17 @@ abstract class ImplOrTraitItemNode extends ItemNode {
561561

562562
pragma[nomagic]
563563
private TypeParamItemNode resolveTypeParamPathTypeRepr(PathTypeRepr ptr) {
564-
result = resolvePathFull(ptr.getPath())
564+
result = resolvePath(ptr.getPath())
565565
}
566566

567567
class ImplItemNode extends ImplOrTraitItemNode instanceof Impl {
568568
Path getSelfPath() { result = super.getSelfTy().(PathTypeRepr).getPath() }
569569

570570
Path getTraitPath() { result = super.getTrait().(PathTypeRepr).getPath() }
571571

572-
ItemNode resolveSelfTy() { result = resolvePathFull(this.getSelfPath()) }
572+
ItemNode resolveSelfTy() { result = resolvePath(this.getSelfPath()) }
573573

574-
TraitItemNode resolveTraitTy() { result = resolvePathFull(this.getTraitPath()) }
574+
TraitItemNode resolveTraitTy() { result = resolvePath(this.getTraitPath()) }
575575

576576
override AssocItemNode getAnAssocItem() { result = super.getAssocItemList().getAnAssocItem() }
577577

@@ -795,7 +795,7 @@ class TraitItemNode extends ImplOrTraitItemNode, TypeItemNode instanceof Trait {
795795
}
796796

797797
pragma[nomagic]
798-
ItemNode resolveABound() { result = resolvePathFull(this.getABoundPath()) }
798+
ItemNode resolveABound() { result = resolvePath(this.getABoundPath()) }
799799

800800
override AssocItemNode getAnAssocItem() { result = super.getAssocItemList().getAnAssocItem() }
801801

@@ -941,7 +941,7 @@ class TypeParamItemNode extends TypeItemNode instanceof TypeParam {
941941
}
942942

943943
pragma[nomagic]
944-
ItemNode resolveABound() { result = resolvePathFull(this.getABoundPath()) }
944+
ItemNode resolveABound() { result = resolvePath(this.getABoundPath()) }
945945

946946
/**
947947
* Holds if this type parameter has a trait bound. Examples:
@@ -1369,14 +1369,9 @@ private predicate pathUsesNamespace(Path p, Namespace n) {
13691369
)
13701370
}
13711371

1372-
/**
1373-
* Gets the item that `path` resolves to, if any.
1374-
*
1375-
* Whenever `path` can resolve to both a function in source code and in library
1376-
* code, both are included
1377-
*/
1378-
pragma[nomagic]
1379-
private ItemNode resolvePathFull(RelevantPath path) {
1372+
/** Gets the item that `path` resolves to, if any. */
1373+
cached
1374+
ItemNode resolvePath(RelevantPath path) {
13801375
exists(Namespace ns | result = resolvePath0(path, ns) |
13811376
pathUsesNamespace(path, ns)
13821377
or
@@ -1385,30 +1380,9 @@ private ItemNode resolvePathFull(RelevantPath path) {
13851380
)
13861381
}
13871382

1388-
pragma[nomagic]
1389-
private predicate resolvesSourceFunction(RelevantPath path) {
1390-
resolvePathFull(path).(Function).fromSource()
1391-
}
1392-
1393-
/** Gets the item that `path` resolves to, if any. */
1394-
cached
1395-
ItemNode resolvePath(RelevantPath path) {
1396-
result = resolvePathFull(path) and
1397-
(
1398-
// when a function exists in both source code and in library code, it is because
1399-
// we also extracted the source code as library code, and hence we only want
1400-
// the function from source code
1401-
result.fromSource()
1402-
or
1403-
not result instanceof Function
1404-
or
1405-
not resolvesSourceFunction(path)
1406-
)
1407-
}
1408-
14091383
pragma[nomagic]
14101384
private ItemNode resolvePathQualifier(RelevantPath path, string name) {
1411-
result = resolvePathFull(path.getQualifier()) and
1385+
result = resolvePath(path.getQualifier()) and
14121386
name = path.getText()
14131387
}
14141388

@@ -1454,7 +1428,7 @@ private ItemNode resolveUseTreeListItemQualifier(
14541428
pragma[nomagic]
14551429
private ItemNode resolveUseTreeListItem(Use use, UseTree tree) {
14561430
tree = use.getUseTree() and
1457-
result = resolvePathFull(tree.getPath())
1431+
result = resolvePath(tree.getPath())
14581432
or
14591433
result = resolveUseTreeListItem(use, tree, tree.getPath())
14601434
}

0 commit comments

Comments
 (0)