@@ -1559,7 +1559,6 @@ private predicate unqualifiedPathLookup(ItemNode ancestor, string name, Namespac
15591559 exists ( RelevantPath path |
15601560 path .isUnqualified ( name , encl ) and
15611561 ancestor = encl and
1562- exists ( ns ) and
15631562 not name = [ "crate" , "$crate" , "super" , "self" ]
15641563 |
15651564 pathUsesNamespace ( path , ns )
@@ -1668,7 +1667,7 @@ module TraitIsVisible<relevantTraitVisibleSig/2 relevantTraitVisible> {
16681667}
16691668
16701669pragma [ nomagic]
1671- private predicate isMacroExpansion ( AstNode expansion , Path macroDefPath ) {
1670+ private predicate isDollarCrateSupportedMacroExpansion ( Path macroDefPath , AstNode expansion ) {
16721671 exists ( MacroCall mc |
16731672 expansion = mc .getMacroCallExpansion ( ) and
16741673 macroDefPath = mc .getPath ( )
@@ -1681,25 +1680,25 @@ private predicate isMacroExpansion(AstNode expansion, Path macroDefPath) {
16811680}
16821681
16831682pragma [ nomagic]
1684- predicate isInMacroExpansion ( Path macroDefPath , AstNode n ) {
1685- isMacroExpansion ( n , macroDefPath )
1683+ predicate isInDollarCrateSupportedMacroExpansion ( File macroDefFile , AstNode n ) {
1684+ exists ( Path macroDefPath |
1685+ isDollarCrateSupportedMacroExpansion ( macroDefPath , n ) and
1686+ macroDefFile = resolvePathCand ( macroDefPath ) .getFile ( )
1687+ )
16861688 or
1687- isInMacroExpansion ( macroDefPath , n .getParentNode ( ) )
1689+ isInDollarCrateSupportedMacroExpansion ( macroDefFile , n .getParentNode ( ) )
16881690}
16891691
16901692/**
1691- * Holds if `n` is inside a macro expansion, and the macro _may_ originate from
1692- * crate `crate`.
1693+ * Holds if `n` is a `$crate` path, and it may resolve to `crate`.
16931694 *
16941695 * The reason why we cannot be sure is that we need to consider all ancestor macro
16951696 * calls.
16961697 */
16971698pragma [ nomagic]
1698- predicate isInMacroFromCrateExpansion ( CrateItemNode crate , AstNode n ) {
1699- exists ( Path macroDefPath |
1700- isInMacroExpansion ( macroDefPath , n ) and
1701- crate .getASourceFile ( ) .getFile ( ) = resolvePathCand ( macroDefPath ) .getFile ( )
1702- )
1699+ predicate resolveDollarCrate ( RelevantPath p , CrateItemNode crate ) {
1700+ p .isDollarCrate ( ) and
1701+ isInDollarCrateSupportedMacroExpansion ( crate .getASourceFile ( ) .getFile ( ) , p )
17031702}
17041703
17051704pragma [ nomagic]
@@ -1714,8 +1713,7 @@ private ItemNode resolvePathCand0(RelevantPath path, Namespace ns) {
17141713 else result = res
17151714 )
17161715 or
1717- path .isDollarCrate ( ) and
1718- isInMacroFromCrateExpansion ( result , path ) and
1716+ resolveDollarCrate ( path , result ) and
17191717 ns = result .getNamespace ( )
17201718 or
17211719 result = resolvePathCandQualified ( _, _, path , ns )
0 commit comments