@@ -2020,8 +2020,24 @@ private ItemNode resolvePathCand(PathExt path) {
20202020
20212021/** Get a trait that should be visible when `path` resolves to `node`, if any. */
20222022private Trait getResolvePathTraitUsed ( PathExt path , AssocItemNode node ) {
2023- exists ( TypeItemNode type , ImplItemNodeImpl impl |
2024- node = resolvePathCandQualified ( _, type , path , _) and
2023+ // exists(TypeItemNode type, ImplItemNodeImpl impl |
2024+ // node = resolvePathCandQualified(_, type, path, _) and
2025+ // typeImplEdge(type, impl, _, node) and
2026+ // result = impl.resolveTraitTyCand()
2027+ // )
2028+ // exists(ItemNode qq |
2029+ // node = resolvePathCandQualified(_, qq, path, _) and
2030+ // not qq instanceof Trait and
2031+ // not qq instanceof TypeParam and
2032+ // (
2033+ // result.(TraitItemNode).getAnAssocItem() = node
2034+ // or
2035+ // result = any(ImplItemNodeImpl impl | impl.getAnAssocItem() = node).resolveTraitTyCand()
2036+ // )
2037+ // )
2038+ exists ( TypeItemNode type , ItemNode qual , ImplItemNodeImpl impl |
2039+ node = resolvePathCandQualified ( _, qual , path , _) and
2040+ type = [ qual , qual .( ImplItemNodeImpl ) .resolveSelfTyCand ( ) ] and
20252041 typeImplEdge ( type , impl , _, node ) and
20262042 result = impl .resolveTraitTyCand ( )
20272043 )
@@ -2250,13 +2266,48 @@ private module Debug {
22502266 Locatable getRelevantLocatable ( ) {
22512267 exists ( string filepath , int startline , int startcolumn , int endline , int endcolumn |
22522268 result .getLocation ( ) .hasLocationInfo ( filepath , startline , startcolumn , endline , endcolumn ) and
2253- // filepath.matches("%/lex .rs") and
2254- // startline = [156 .. 163 ]
2255- filepath .matches ( "%/algorithm/mod .rs" ) and
2256- startline = [ 300 .. 303 ]
2269+ filepath .matches ( "%/array .rs" ) and
2270+ startline = [ 272 .. 291 ]
2271+ // filepath.matches("%/main .rs") and
2272+ // startline = [612 ]
22572273 )
22582274 }
22592275
2276+ private Trait debugGetResolvePathTraitUsed ( PathExt path , AssocItemNode node ) {
2277+ path .toString ( ) = "Self::empty" and
2278+ path = getRelevantLocatable ( ) and
2279+ result = getResolvePathTraitUsed ( path , node )
2280+ }
2281+
2282+ predicate resolveSelf (
2283+ Path p , ItemNode s , ImplOrTraitItemNode fr1 , ItemNode cand , ImplOrTraitItemNode fr2 , ItemNode it
2284+ ) {
2285+ p = getRelevantLocatable ( ) and
2286+ p .toString ( ) = "Self::empty" and
2287+ cand = resolvePathCand ( p ) and
2288+ fr1 .getAnAssocItem ( ) = cand and
2289+ it = resolvePathIgnoreVariableShadowing ( p ) and
2290+ fr2 .getAnAssocItem ( ) = it and
2291+ s = resolvePathCand ( p .getQualifier ( ) )
2292+ }
2293+
2294+ predicate path (
2295+ Path p , Function f , ImplItemNode i , ItemNode ty , ImplOrTraitItemNode frm , ItemNode succ
2296+ ) {
2297+ p = getRelevantLocatable ( ) and
2298+ p .toString ( ) = "Self::empty" and
2299+ p .getParentNode * ( ) = f and
2300+ p .getParentNode * ( ) = i and
2301+ // ty = i.getSelfTy() and
2302+ i .resolveSelfTy ( ) = ty and
2303+ frm .getAnAssocItem ( ) = succ and
2304+ ty .getASuccessor ( "empty" ) = succ
2305+ }
2306+
2307+ // predicate bbbb(Path p, Impl i, string name) {
2308+ // path(p, _, i, _) and
2309+ // relevantSelfFunctionName(i, name)
2310+ // }
22602311 predicate debugUnqualifiedPathLookup (
22612312 PathExt p , string name , Namespace ns , ItemNode ancestor , string path
22622313 ) {
0 commit comments