@@ -233,15 +233,15 @@ abstract class ItemNode extends Locatable {
233
233
// a trait has access to the associated items of its supertraits
234
234
this =
235
235
any ( TraitItemNodeImpl trait |
236
- result = trait .resolveABound ( ) .getASuccessor ( name , kind ) and
236
+ result = trait .resolveABoundCand ( ) .getASuccessor ( name , kind ) and
237
237
kind .isExternalOrBoth ( ) and
238
238
result instanceof AssocItemNode and
239
239
not trait .hasAssocItem ( name )
240
240
)
241
241
or
242
242
// items made available by an implementation where `this` is the implementing type
243
243
exists ( ItemNode node |
244
- this = node .( ImplItemNodeImpl ) .resolveSelfTy ( ) and
244
+ this = node .( ImplItemNodeImpl ) .resolveSelfTyCand ( ) and
245
245
result = node .getASuccessor ( name , kind ) and
246
246
kind .isExternalOrBoth ( ) and
247
247
result instanceof AssocItemNode
@@ -250,22 +250,26 @@ abstract class ItemNode extends Locatable {
250
250
// trait items with default implementations made available in an implementation
251
251
exists ( ImplItemNodeImpl impl , ItemNode trait |
252
252
this = impl and
253
- trait = impl .resolveTraitTy ( ) and
253
+ trait = impl .resolveTraitTyCand ( ) and
254
254
result = trait .getASuccessor ( name , kind ) and
255
255
result .( AssocItemNode ) .hasImplementation ( ) and
256
256
kind .isExternalOrBoth ( ) and
257
257
not impl .hasAssocItem ( name )
258
258
)
259
259
or
260
260
// type parameters have access to the associated items of its bounds
261
- result = this .( TypeParamItemNodeImpl ) .resolveABound ( ) .getASuccessor ( name , kind ) .( AssocItemNode ) and
261
+ result =
262
+ this .( TypeParamItemNodeImpl ) .resolveABoundCand ( ) .getASuccessor ( name , kind ) .( AssocItemNode ) and
262
263
kind .isExternalOrBoth ( )
263
264
or
264
265
result =
265
- this .( ImplTraitTypeReprItemNodeImpl ) .resolveABound ( ) .getASuccessor ( name , kind ) .( AssocItemNode ) and
266
+ this .( ImplTraitTypeReprItemNodeImpl )
267
+ .resolveABoundCand ( )
268
+ .getASuccessor ( name , kind )
269
+ .( AssocItemNode ) and
266
270
kind .isExternalOrBoth ( )
267
271
or
268
- result = this .( TypeAliasItemNodeImpl ) .resolveAlias ( ) .getASuccessor ( name , kind ) and
272
+ result = this .( TypeAliasItemNodeImpl ) .resolveAliasCand ( ) .getASuccessor ( name , kind ) and
269
273
kind .isExternalOrBoth ( )
270
274
or
271
275
name = "super" and
@@ -746,7 +750,7 @@ final private class ImplTraitTypeReprItemNode extends TypeItemNode instanceof Im
746
750
747
751
private class ImplTraitTypeReprItemNodeImpl extends ImplTraitTypeReprItemNode {
748
752
pragma [ nomagic]
749
- ItemNode resolveABound ( ) { result = resolvePathCand ( this .getABoundPath ( ) ) }
753
+ ItemNode resolveABoundCand ( ) { result = resolvePathCand ( this .getABoundPath ( ) ) }
750
754
}
751
755
752
756
private class ModuleItemNode extends ModuleLikeNode instanceof Module {
@@ -792,9 +796,9 @@ private class ModuleItemNode extends ModuleLikeNode instanceof Module {
792
796
}
793
797
794
798
private class ImplItemNodeImpl extends ImplItemNode {
795
- TypeItemNode resolveSelfTy ( ) { result = resolvePathCand ( this .getSelfPath ( ) ) }
799
+ TypeItemNode resolveSelfTyCand ( ) { result = resolvePathCand ( this .getSelfPath ( ) ) }
796
800
797
- TraitItemNode resolveTraitTy ( ) { result = resolvePathCand ( this .getTraitPath ( ) ) }
801
+ TraitItemNode resolveTraitTyCand ( ) { result = resolvePathCand ( this .getTraitPath ( ) ) }
798
802
}
799
803
800
804
private class StructItemNode extends TypeItemNode instanceof Struct {
@@ -889,7 +893,7 @@ final class TraitItemNode extends ImplOrTraitItemNode, TypeItemNode instanceof T
889
893
890
894
final private class TraitItemNodeImpl extends TraitItemNode {
891
895
pragma [ nomagic]
892
- ItemNode resolveABound ( ) { result = resolvePathCand ( this .getABoundPath ( ) ) }
896
+ ItemNode resolveABoundCand ( ) { result = resolvePathCand ( this .getABoundPath ( ) ) }
893
897
}
894
898
895
899
final class TypeAliasItemNode extends TypeItemNode , AssocItemNode instanceof TypeAlias {
@@ -913,7 +917,9 @@ final class TypeAliasItemNode extends TypeItemNode, AssocItemNode instanceof Typ
913
917
914
918
private class TypeAliasItemNodeImpl extends TypeAliasItemNode instanceof TypeAlias {
915
919
pragma [ nomagic]
916
- ItemNode resolveAlias ( ) { result = resolvePathCand ( super .getTypeRepr ( ) .( PathTypeRepr ) .getPath ( ) ) }
920
+ ItemNode resolveAliasCand ( ) {
921
+ result = resolvePathCand ( super .getTypeRepr ( ) .( PathTypeRepr ) .getPath ( ) )
922
+ }
917
923
}
918
924
919
925
private class UnionItemNode extends TypeItemNode instanceof Union {
@@ -1053,7 +1059,7 @@ final class TypeParamItemNode extends TypeItemNode instanceof TypeParam {
1053
1059
final private class TypeParamItemNodeImpl extends TypeParamItemNode instanceof TypeParam {
1054
1060
/** Gets a where predicate for this type parameter, if any */
1055
1061
pragma [ nomagic]
1056
- private WherePred getAWherePred ( ) {
1062
+ private WherePred getAWherePredCand ( ) {
1057
1063
exists ( ItemNode declaringItem |
1058
1064
this = resolvePathCand ( getWherePredPath ( result ) ) and
1059
1065
result = declaringItem .getADescendant ( ) and
@@ -1062,23 +1068,25 @@ final private class TypeParamItemNodeImpl extends TypeParamItemNode instanceof T
1062
1068
}
1063
1069
1064
1070
pragma [ nomagic]
1065
- TypeBound getTypeBoundAt ( int i , int j ) {
1071
+ TypeBound getTypeBoundAtCand ( int i , int j ) {
1066
1072
exists ( TypeBoundList tbl | result = tbl .getBound ( j ) |
1067
1073
tbl = super .getTypeBoundList ( ) and i = 0
1068
1074
or
1069
1075
exists ( WherePred wp |
1070
- wp = this .getAWherePred ( ) and
1076
+ wp = this .getAWherePredCand ( ) and
1071
1077
tbl = wp .getTypeBoundList ( ) and
1072
1078
wp = any ( WhereClause wc ) .getPredicate ( i )
1073
1079
)
1074
1080
)
1075
1081
}
1076
1082
1077
1083
pragma [ nomagic]
1078
- Path getABoundPath ( ) { result = this .getTypeBoundAt ( _, _) .getTypeRepr ( ) .( PathTypeRepr ) .getPath ( ) }
1084
+ Path getABoundPathCand ( ) {
1085
+ result = this .getTypeBoundAtCand ( _, _) .getTypeRepr ( ) .( PathTypeRepr ) .getPath ( )
1086
+ }
1079
1087
1080
1088
pragma [ nomagic]
1081
- ItemNode resolveABound ( ) { result = resolvePathCand ( this .getABoundPath ( ) ) }
1089
+ ItemNode resolveABoundCand ( ) { result = resolvePathCand ( this .getABoundPathCand ( ) ) }
1082
1090
}
1083
1091
1084
1092
/** Holds if `item` has the name `name` and is a top-level item inside `f`. */
@@ -1245,7 +1253,10 @@ private predicate crateDependencyEdge(SourceFileItemNode file, string name, Crat
1245
1253
crateDependency ( file , name , dep )
1246
1254
or
1247
1255
// As a fallback, give all files access to crates that do not conflict with known dependencies
1248
- // and declarations.
1256
+ // and declarations. This is in order to workaround incomplete crate dependency information
1257
+ // provided by the extractor, as well as `CrateItemNode.getASourceFile()` being unable to map
1258
+ // a given file to its crate (for example, if the file is `mod` imported inside a macro that the
1259
+ // extractor is unable to expand).
1249
1260
name = dep .getName ( ) and
1250
1261
not declaresDirectly ( file , TTypeNamespace ( ) , name ) and
1251
1262
not crateDependency ( file , name , _)
@@ -1418,7 +1429,7 @@ private ItemNode resolvePathCand0(RelevantPath path, Namespace ns) {
1418
1429
not any ( RelevantPath parent ) .getQualifier ( ) = path and
1419
1430
isUnqualifiedSelfPath ( path ) and
1420
1431
res instanceof ImplItemNode
1421
- then result = res .( ImplItemNodeImpl ) .resolveSelfTy ( )
1432
+ then result = res .( ImplItemNodeImpl ) .resolveSelfTyCand ( )
1422
1433
else result = res
1423
1434
)
1424
1435
or
@@ -1482,6 +1493,9 @@ private predicate pathUsesNamespace(Path p, Namespace n) {
1482
1493
* Unlike `resolvePath`, this predicate does not attempt to make resolution
1483
1494
* of qualifiers consistent with resolution of their parents, and should
1484
1495
* only be used internally within this library.
1496
+ *
1497
+ * Note that the path resolution logic cannot use `resolvePath`, as that would
1498
+ * result in non-monotonic recursion.
1485
1499
*/
1486
1500
pragma [ nomagic]
1487
1501
private ItemNode resolvePathCand ( RelevantPath path ) {
@@ -1515,16 +1529,10 @@ ItemNode resolvePath(RelevantPath path) {
1515
1529
// if `path` is the qualifier of a resolvable `parent`, then we should
1516
1530
// resolve `path` to something consistent with what `parent` resolves to
1517
1531
exists ( RelevantPath parent |
1518
- resolvePathCandQualified ( path , result , parent , _) = resolvePathParent ( path , parent )
1532
+ resolvePathCandQualified ( path , result , parent , _) = resolvePath ( parent )
1519
1533
)
1520
1534
}
1521
1535
1522
- pragma [ nomagic]
1523
- private ItemNode resolvePathParent ( RelevantPath path , RelevantPath parent ) {
1524
- result = resolvePath ( parent ) and
1525
- path = parent .getQualifier ( )
1526
- }
1527
-
1528
1536
private predicate isUseTreeSubPath ( UseTree tree , RelevantPath path ) {
1529
1537
path = tree .getPath ( )
1530
1538
or
0 commit comments