@@ -882,20 +882,24 @@ private predicate hasChild(ItemNode parent, ItemNode child) { child.getImmediate
882
882
private predicate rootHasCratePathTc ( ItemNode i1 , ItemNode i2 ) =
883
883
doublyBoundedFastTC( hasChild / 2 , isRoot / 1 , hasCratePath / 1 ) ( i1 , i2 )
884
884
885
+ pragma [ nomagic]
886
+ private predicate unqualifiedPathLookup1 ( RelevantPath p , string name , Namespace ns , ItemNode encl ) {
887
+ unqualifiedPathLookup ( p , name , ns , encl )
888
+ or
889
+ // For `($)crate`, jump directly to the root module
890
+ exists ( ItemNode i | p .isCratePath ( name , i ) |
891
+ encl .( ModuleLikeNode ) .isRoot ( ) and
892
+ encl = i
893
+ or
894
+ rootHasCratePathTc ( encl , i )
895
+ )
896
+ }
897
+
885
898
pragma [ nomagic]
886
899
private ItemNode unqualifiedPathLookup ( RelevantPath path , Namespace ns ) {
887
900
exists ( ItemNode encl , string name |
888
- result = getASuccessor ( encl , pragma [ only_bind_into ] ( name ) , ns )
889
- |
890
- unqualifiedPathLookup ( path , name , ns , encl )
891
- or
892
- // For `($)crate`, jump directly to the root module
893
- exists ( ItemNode i | path .isCratePath ( pragma [ only_bind_into ] ( name ) , i ) |
894
- encl .( ModuleLikeNode ) .isRoot ( ) and
895
- encl = i
896
- or
897
- rootHasCratePathTc ( encl , i )
898
- )
901
+ result = getASuccessor ( encl , name , ns ) and
902
+ unqualifiedPathLookup1 ( path , name , ns , encl )
899
903
)
900
904
}
901
905
@@ -916,8 +920,7 @@ private ItemNode resolvePath0(RelevantPath path, Namespace ns) {
916
920
or
917
921
exists ( ItemNode q , string name |
918
922
q = resolvePathQualifier ( path , name ) and
919
- result = q .getASuccessor ( name ) and
920
- ns = result .getNamespace ( )
923
+ result = getASuccessor ( q , name , ns )
921
924
)
922
925
or
923
926
result = resolveUseTreeListItem ( _, _, path ) and
@@ -978,6 +981,11 @@ private ItemNode resolvePathPrivate(
978
981
)
979
982
}
980
983
984
+ pragma [ nomagic]
985
+ private predicate isItemParent ( ModuleLikeNode itemParent ) {
986
+ exists ( resolvePathPrivate ( _, itemParent , _) )
987
+ }
988
+
981
989
/**
982
990
* Gets a module that has access to private items defined inside `itemParent`.
983
991
*
@@ -988,7 +996,7 @@ private ItemNode resolvePathPrivate(
988
996
*/
989
997
pragma [ nomagic]
990
998
private ModuleLikeNode getAPrivateVisibleModule ( ModuleLikeNode itemParent ) {
991
- exists ( resolvePathPrivate ( _ , itemParent , _ ) ) and
999
+ isItemParent ( itemParent ) and
992
1000
result .getImmediateParentModule * ( ) = itemParent
993
1001
}
994
1002
0 commit comments