@@ -882,20 +882,24 @@ private predicate hasChild(ItemNode parent, ItemNode child) { child.getImmediate
882882private predicate rootHasCratePathTc ( ItemNode i1 , ItemNode i2 ) =
883883 doublyBoundedFastTC( hasChild / 2 , isRoot / 1 , hasCratePath / 1 ) ( i1 , i2 )
884884
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+
885898pragma [ nomagic]
886899private ItemNode unqualifiedPathLookup ( RelevantPath path , Namespace ns ) {
887900 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 )
899903 )
900904}
901905
@@ -916,8 +920,7 @@ private ItemNode resolvePath0(RelevantPath path, Namespace ns) {
916920 or
917921 exists ( ItemNode q , string name |
918922 q = resolvePathQualifier ( path , name ) and
919- result = q .getASuccessor ( name ) and
920- ns = result .getNamespace ( )
923+ result = getASuccessor ( q , name , ns )
921924 )
922925 or
923926 result = resolveUseTreeListItem ( _, _, path ) and
@@ -978,6 +981,11 @@ private ItemNode resolvePathPrivate(
978981 )
979982}
980983
984+ pragma [ nomagic]
985+ private predicate isItemParent ( ModuleLikeNode itemParent ) {
986+ exists ( resolvePathPrivate ( _, itemParent , _) )
987+ }
988+
981989/**
982990 * Gets a module that has access to private items defined inside `itemParent`.
983991 *
@@ -988,7 +996,7 @@ private ItemNode resolvePathPrivate(
988996 */
989997pragma [ nomagic]
990998private ModuleLikeNode getAPrivateVisibleModule ( ModuleLikeNode itemParent ) {
991- exists ( resolvePathPrivate ( _ , itemParent , _ ) ) and
999+ isItemParent ( itemParent ) and
9921000 result .getImmediateParentModule * ( ) = itemParent
9931001}
9941002
0 commit comments