@@ -1802,13 +1802,6 @@ private module AssocFunctionResolution {
18021802 result != TUnknownType ( )
18031803 }
18041804
1805- private Type testgetComplexStrippedSelfType (
1806- FunctionPosition selfPos , DerefChain derefChain , BorrowKind borrow , TypePath strippedTypePath
1807- ) {
1808- result = this .getComplexStrippedSelfType ( selfPos , derefChain , borrow , strippedTypePath ) and
1809- this = Debug:: getRelevantLocatable ( )
1810- }
1811-
18121805 pragma [ nomagic]
18131806 Type getComplexStrippedSelfType (
18141807 FunctionPosition selfPos , DerefChain derefChain , BorrowKind borrow , TypePath strippedTypePath
@@ -1827,8 +1820,7 @@ private module AssocFunctionResolution {
18271820 */
18281821 pragma [ nomagic]
18291822 predicate hasNoCompatibleTargetNoBorrow ( FunctionPosition selfPos , DerefChain derefChain ) {
1830- Foo< hasNoCompatibleTargetNoBorrowToIndex / 4 > :: hasNoCompatibleTargetCheck ( this , selfPos ,
1831- derefChain , _)
1823+ HasNoCompatibleTargetNoBorrow:: hasNoCompatibleTarget ( this , selfPos , derefChain , _)
18321824 }
18331825
18341826 /**
@@ -1839,8 +1831,8 @@ private module AssocFunctionResolution {
18391831 predicate hasNoCompatibleNonBlanketTargetNoBorrow (
18401832 FunctionPosition selfPos , DerefChain derefChain
18411833 ) {
1842- Foo < hasNoCompatibleNonBlanketTargetNoBorrowToIndex / 4 > :: hasNoCompatibleNonBlanketTargetCheck ( this ,
1843- selfPos , derefChain , _)
1834+ HasNoCompatibleNonBlanketTargetNoBorrow :: hasNoCompatibleNonBlanketTarget ( this , selfPos ,
1835+ derefChain , _)
18441836 }
18451837
18461838 /**
@@ -1850,8 +1842,8 @@ private module AssocFunctionResolution {
18501842 */
18511843 pragma [ nomagic]
18521844 predicate hasNoCompatibleTargetSharedBorrow ( FunctionPosition selfPos , DerefChain derefChain ) {
1853- Foo < hasNoCompatibleTargetSharedBorrowToIndex / 4 > :: hasNoCompatibleNonBlanketLikeTargetCheck ( this ,
1854- selfPos , derefChain , _)
1845+ HasNoCompatibleTargetSharedBorrow :: hasNoCompatibleNonBlanketLikeTarget ( this , selfPos ,
1846+ derefChain , _)
18551847 }
18561848
18571849 /**
@@ -1861,8 +1853,8 @@ private module AssocFunctionResolution {
18611853 */
18621854 pragma [ nomagic]
18631855 predicate hasNoCompatibleTargetMutBorrow ( FunctionPosition selfPos , DerefChain derefChain ) {
1864- Foo < hasNoCompatibleTargetMutBorrowToIndex / 4 > :: hasNoCompatibleNonBlanketLikeTargetCheck ( this ,
1865- selfPos , derefChain , _)
1856+ HasNoCompatibleTargetMutBorrow :: hasNoCompatibleNonBlanketLikeTarget ( this , selfPos , derefChain ,
1857+ _)
18661858 }
18671859
18681860 /**
@@ -1874,8 +1866,8 @@ private module AssocFunctionResolution {
18741866 predicate hasNoCompatibleNonBlanketTargetSharedBorrow (
18751867 FunctionPosition selfPos , DerefChain derefChain
18761868 ) {
1877- Foo < hasNoCompatibleNonBlanketTargetSharedBorrowToIndex / 4 > :: hasNoCompatibleNonBlanketTargetCheck ( this ,
1878- selfPos , derefChain , _)
1869+ HasNoCompatibleNonBlanketTargetSharedBorrow :: hasNoCompatibleNonBlanketTarget ( this , selfPos ,
1870+ derefChain , _)
18791871 }
18801872
18811873 /**
@@ -1887,8 +1879,8 @@ private module AssocFunctionResolution {
18871879 predicate hasNoCompatibleNonBlanketTargetMutBorrow (
18881880 FunctionPosition selfPos , DerefChain derefChain
18891881 ) {
1890- Foo < hasNoCompatibleNonBlanketTargetMutBorrowToIndex / 4 > :: hasNoCompatibleNonBlanketTargetCheck ( this ,
1891- selfPos , derefChain , _)
1882+ HasNoCompatibleNonBlanketTargetMutBorrow :: hasNoCompatibleNonBlanketTarget ( this , selfPos ,
1883+ derefChain , _)
18921884 }
18931885
18941886 /**
@@ -1990,7 +1982,20 @@ private module AssocFunctionResolution {
19901982 }
19911983
19921984 bindingset [ derefChain]
1993- private predicate hasNoCompatibleNonBlanketTargetNoBorrowToIndex (
1985+ private predicate hasNoCompatibleTargetNoBorrowCand (
1986+ AssocFunctionCall afc , FunctionPosition selfPos , DerefChain derefChain , BorrowKind borrow
1987+ ) {
1988+ afc .supportsAutoDerefAndBorrow ( ) and
1989+ afc .hasReceiverAtPos ( selfPos ) and
1990+ exists ( derefChain ) and
1991+ borrow = TNoBorrowKind ( )
1992+ }
1993+
1994+ private module HasNoCompatibleTargetNoBorrow =
1995+ NoCompatibleTargetChecks< hasNoCompatibleTargetNoBorrowCand / 4 > ;
1996+
1997+ bindingset [ derefChain]
1998+ private predicate hasNoCompatibleNonBlanketTargetNoBorrowCand (
19941999 AssocFunctionCall afc , FunctionPosition selfPos , DerefChain derefChain , BorrowKind borrow
19952000 ) {
19962001 (
@@ -2009,48 +2014,53 @@ private module AssocFunctionResolution {
20092014 borrow = TNoBorrowKind ( )
20102015 }
20112016
2017+ private module HasNoCompatibleNonBlanketTargetNoBorrow =
2018+ NoCompatibleTargetChecks< hasNoCompatibleNonBlanketTargetNoBorrowCand / 4 > ;
2019+
20122020 pragma [ nomagic]
2013- private predicate hasNoCompatibleNonBlanketTargetSharedBorrowToIndex (
2021+ private predicate hasNoCompatibleTargetSharedBorrowCand (
20142022 AssocFunctionCall afc , FunctionPosition selfPos , DerefChain derefChain , BorrowKind borrow
20152023 ) {
20162024 afc .hasNoCompatibleTargetNoBorrow ( selfPos , derefChain ) and
20172025 borrow = TSomeBorrowKind ( false )
20182026 }
20192027
2028+ private module HasNoCompatibleTargetSharedBorrow =
2029+ NoCompatibleTargetChecks< hasNoCompatibleTargetSharedBorrowCand / 4 > ;
2030+
20202031 pragma [ nomagic]
2021- private predicate hasNoCompatibleNonBlanketTargetMutBorrowToIndex (
2032+ private predicate hasNoCompatibleTargetMutBorrowCand (
20222033 AssocFunctionCall afc , FunctionPosition selfPos , DerefChain derefChain , BorrowKind borrow
20232034 ) {
2024- afc .hasNoCompatibleNonBlanketTargetSharedBorrow ( selfPos , derefChain ) and
2035+ afc .hasNoCompatibleTargetSharedBorrow ( selfPos , derefChain ) and
20252036 borrow = TSomeBorrowKind ( true )
20262037 }
20272038
2028- bindingset [ derefChain]
2029- private predicate hasNoCompatibleTargetNoBorrowToIndex (
2030- AssocFunctionCall afc , FunctionPosition selfPos , DerefChain derefChain , BorrowKind borrow
2031- ) {
2032- afc .supportsAutoDerefAndBorrow ( ) and
2033- afc .hasReceiverAtPos ( selfPos ) and
2034- exists ( derefChain ) and
2035- borrow = TNoBorrowKind ( )
2036- }
2039+ private module HasNoCompatibleTargetMutBorrow =
2040+ NoCompatibleTargetChecks< hasNoCompatibleTargetMutBorrowCand / 4 > ;
20372041
20382042 pragma [ nomagic]
2039- private predicate hasNoCompatibleTargetSharedBorrowToIndex (
2043+ private predicate hasNoCompatibleNonBlanketTargetSharedBorrowCand (
20402044 AssocFunctionCall afc , FunctionPosition selfPos , DerefChain derefChain , BorrowKind borrow
20412045 ) {
20422046 afc .hasNoCompatibleTargetNoBorrow ( selfPos , derefChain ) and
20432047 borrow = TSomeBorrowKind ( false )
20442048 }
20452049
2050+ private module HasNoCompatibleNonBlanketTargetSharedBorrow =
2051+ NoCompatibleTargetChecks< hasNoCompatibleNonBlanketTargetSharedBorrowCand / 4 > ;
2052+
20462053 pragma [ nomagic]
2047- private predicate hasNoCompatibleTargetMutBorrowToIndex (
2054+ private predicate hasNoCompatibleNonBlanketTargetMutBorrowCand (
20482055 AssocFunctionCall afc , FunctionPosition selfPos , DerefChain derefChain , BorrowKind borrow
20492056 ) {
2050- afc .hasNoCompatibleTargetSharedBorrow ( selfPos , derefChain ) and
2057+ afc .hasNoCompatibleNonBlanketTargetSharedBorrow ( selfPos , derefChain ) and
20512058 borrow = TSomeBorrowKind ( true )
20522059 }
20532060
2061+ private module HasNoCompatibleNonBlanketTargetMutBorrow =
2062+ NoCompatibleTargetChecks< hasNoCompatibleNonBlanketTargetMutBorrowCand / 4 > ;
2063+
20542064 private import codeql.rust.elements.internal.generated.Raw
20552065 private import codeql.rust.elements.internal.generated.Synth
20562066
@@ -2065,44 +2075,36 @@ private module AssocFunctionResolution {
20652075 }
20662076
20672077 bindingset [ derefChain]
2068- private signature predicate fooSig (
2078+ private signature predicate noCompatibleTargetCandSig (
20692079 AssocFunctionCall afc , FunctionPosition selfPos , DerefChain derefChain , BorrowKind borrow
20702080 ) ;
20712081
2072- private module Foo < fooSig / 4 foo > {
2082+ private module NoCompatibleTargetChecks < noCompatibleTargetCandSig / 4 noCompatibleTargetCand > {
20732083 pragma [ nomagic]
2074- private predicate foo (
2075- AssocFunctionCall afc , FunctionPosition selfPos , DerefChain derefChain , BorrowKind borrow ,
2076- TypePath strippedTypePath , Type strippedType , int n
2077- ) {
2078- foo ( afc , selfPos , derefChain , borrow ) and
2079- strippedType = afc .getComplexStrippedSelfType ( selfPos , derefChain , borrow , strippedTypePath ) and
2080- n = - 1
2081- }
2082-
2083- pragma [ nomagic]
2084- private predicate bar (
2084+ private predicate noCompatibleNonBlanketLikeTargetCandNthLookupType (
20852085 AssocFunctionCall afc , FunctionPosition selfPos , DerefChain derefChain , BorrowKind borrow ,
20862086 TypePath strippedTypePath , Type strippedType , int n , Type t
20872087 ) {
20882088 (
2089- foo ( afc , selfPos , derefChain , borrow , strippedTypePath , strippedType , n - 1 ) or
2090- hasNoCompatibleNonBlanketLikeTargetCheckToIndex ( afc , selfPos , derefChain , borrow ,
2089+ noCompatibleTargetCand ( afc , selfPos , derefChain , borrow ) and
2090+ strippedType = afc .getComplexStrippedSelfType ( selfPos , derefChain , borrow , strippedTypePath ) and
2091+ n = 0
2092+ or
2093+ hasNoCompatibleNonBlanketLikeTargetForNthLookupType ( afc , selfPos , derefChain , borrow ,
20912094 strippedTypePath , strippedType , n - 1 )
20922095 ) and
20932096 t = getNthLookupType ( afc , strippedType , n )
20942097 }
20952098
20962099 pragma [ nomagic]
2097- private ImplOrTraitItemNode getNthNonBlanketLikeCandidate (
2100+ private ImplOrTraitItemNode getKthNonBlanketLikeCandidateForNthLookupType (
20982101 AssocFunctionCall afc , FunctionPosition selfPos , DerefChain derefChain , BorrowKind borrow ,
2099- TypePath strippedTypePath , Type strippedType , int n , Type t , int rnk
2102+ TypePath strippedTypePath , Type strippedType , int n , Type t , int k
21002103 ) {
2101- bar ( afc , selfPos , derefChain , borrow , strippedTypePath , strippedType , n , t ) and
2102- // foo(afc, selfPos, derefChain, borrow, strippedTypePath, strippedType, _) and
2103- // t = getNthLookupType(afc, strippedType, n) and
2104+ noCompatibleNonBlanketLikeTargetCandNthLookupType ( afc , selfPos , derefChain , borrow ,
2105+ strippedTypePath , strippedType , n , t ) and
21042106 result =
2105- rank [ rnk + 1 ] ( ImplOrTraitItemNode i , int id |
2107+ rank [ k + 1 ] ( ImplOrTraitItemNode i , int id |
21062108 nonBlanketLikeCandidate ( afc , selfPos , i , _, strippedTypePath , t ) and
21072109 id = idOfImplOrTraitItemNode ( i )
21082110 |
@@ -2111,19 +2113,13 @@ private module AssocFunctionResolution {
21112113 }
21122114
21132115 pragma [ nomagic]
2114- private int getLastNonBlanketLikeCandidateIndex (
2116+ private int getLastNonBlanketLikeCandidateForNthLookupType (
21152117 AssocFunctionCall afc , FunctionPosition selfPos , DerefChain derefChain , BorrowKind borrow ,
21162118 TypePath strippedTypePath , Type strippedType , int n
21172119 ) {
2118- // max(int rnk |
2119- // exists(
2120- // getNthNonBlanketLikeCandidate(afc, selfPos, derefChain, borrow, strippedTypePath,
2121- // strippedType, n, t, rnk)
2122- // )
2123- // )
21242120 exists ( Type t |
2125- foo ( afc , selfPos , derefChain , borrow , strippedTypePath , strippedType , _ ) and
2126- t = getNthLookupType ( afc , strippedType , n ) and
2121+ noCompatibleNonBlanketLikeTargetCandNthLookupType ( afc , selfPos , derefChain , borrow ,
2122+ strippedTypePath , strippedType , n , t ) and
21272123 result =
21282124 count ( ImplOrTraitItemNode i |
21292125 nonBlanketLikeCandidate ( afc , selfPos , i , _, strippedTypePath , t )
@@ -2133,73 +2129,67 @@ private module AssocFunctionResolution {
21332129
21342130 // forex using recursion
21352131 pragma [ nomagic]
2136- private predicate hasNoCompatibleNonBlanketLikeTargetCheckToIndexToIndex (
2132+ private predicate hasNoCompatibleNonBlanketLikeTargetForNthLookupTypeToIndex (
21372133 AssocFunctionCall afc , FunctionPosition selfPos , DerefChain derefChain , BorrowKind borrow ,
2138- TypePath strippedTypePath , Type strippedType , int n , int rnk
2134+ TypePath strippedTypePath , Type strippedType , int n , int k
21392135 ) {
2140- // afc = Debug::getRelevantLocatable() and
2141- exists ( Type t | bar ( afc , selfPos , derefChain , borrow , strippedTypePath , strippedType , n , t ) |
2142- rnk = - 1
2136+ exists ( Type t |
2137+ noCompatibleNonBlanketLikeTargetCandNthLookupType ( afc , selfPos , derefChain , borrow ,
2138+ strippedTypePath , strippedType , n , t )
2139+ |
2140+ k = - 1
21432141 or
2144- hasNoCompatibleNonBlanketLikeTargetCheckToIndexToIndex ( afc , selfPos , derefChain , borrow ,
2145- strippedTypePath , strippedType , n , rnk - 1 ) and
2142+ hasNoCompatibleNonBlanketLikeTargetForNthLookupTypeToIndex ( afc , selfPos , derefChain , borrow ,
2143+ strippedTypePath , strippedType , n , k - 1 ) and
21462144 exists ( ImplOrTraitItemNode i |
21472145 i =
2148- getNthNonBlanketLikeCandidate ( afc , selfPos , derefChain , borrow , strippedTypePath ,
2149- strippedType , n , t , rnk ) and
2146+ getKthNonBlanketLikeCandidateForNthLookupType ( afc , selfPos , derefChain , borrow ,
2147+ strippedTypePath , strippedType , n , t , k ) and
21502148 afc .hasIncompatibleTarget ( i , selfPos , derefChain , borrow , t )
21512149 )
21522150 )
21532151 }
21542152
21552153 // forex using recursion
21562154 pragma [ nomagic]
2157- private predicate hasNoCompatibleNonBlanketLikeTargetCheckToIndex (
2155+ private predicate hasNoCompatibleNonBlanketLikeTargetForNthLookupType (
21582156 AssocFunctionCall afc , FunctionPosition selfPos , DerefChain derefChain , BorrowKind borrow ,
21592157 TypePath strippedTypePath , Type strippedType , int n
21602158 ) {
21612159 exists ( int last |
21622160 last =
2163- getLastNonBlanketLikeCandidateIndex ( afc , selfPos , derefChain , borrow , strippedTypePath ,
2164- strippedType , n ) and
2165- hasNoCompatibleNonBlanketLikeTargetCheckToIndexToIndex ( afc , selfPos , derefChain , borrow ,
2161+ getLastNonBlanketLikeCandidateForNthLookupType ( afc , selfPos , derefChain , borrow ,
2162+ strippedTypePath , strippedType , n ) and
2163+ hasNoCompatibleNonBlanketLikeTargetForNthLookupTypeToIndex ( afc , selfPos , derefChain , borrow ,
21662164 strippedTypePath , strippedType , n , last )
21672165 )
2168- // exists(Type t |
2169- // bar(afc, selfPos, derefChain, borrow, strippedTypePath, strippedType, n, t) and
2170- // forall(ImplOrTraitItemNode i |
2171- // nonBlanketLikeCandidate(afc, selfPos, i, _, strippedTypePath, t)
2172- // |
2173- // afc.hasIncompatibleTarget(i, selfPos, derefChain, borrow, t)
2174- // )
2175- // )
21762166 }
21772167
21782168 pragma [ nomagic]
2179- predicate hasNoCompatibleNonBlanketLikeTargetCheck (
2169+ predicate hasNoCompatibleNonBlanketLikeTarget (
21802170 AssocFunctionCall afc , FunctionPosition selfPos , DerefChain derefChain , BorrowKind borrow
21812171 ) {
21822172 exists ( Type strippedType |
2183- hasNoCompatibleNonBlanketLikeTargetCheckToIndex ( afc , selfPos , derefChain , borrow , _,
2173+ hasNoCompatibleNonBlanketLikeTargetForNthLookupType ( afc , selfPos , derefChain , borrow , _,
21842174 strippedType , getLastLookupTypeIndex ( afc , strippedType ) )
21852175 )
21862176 }
21872177
21882178 pragma [ nomagic]
2189- predicate hasNoCompatibleTargetCheck (
2179+ predicate hasNoCompatibleTarget (
21902180 AssocFunctionCall afc , FunctionPosition selfPos , DerefChain derefChain , BorrowKind borrow
21912181 ) {
2192- hasNoCompatibleNonBlanketLikeTargetCheck ( afc , selfPos , derefChain , borrow ) and
2182+ hasNoCompatibleNonBlanketLikeTarget ( afc , selfPos , derefChain , borrow ) and
21932183 forall ( ImplItemNode i | blanketLikeCandidate ( afc , selfPos , i , _, _, _) |
21942184 afc .hasIncompatibleBlanketLikeTarget ( i , selfPos , derefChain , borrow )
21952185 )
21962186 }
21972187
21982188 pragma [ nomagic]
2199- predicate hasNoCompatibleNonBlanketTargetCheck (
2189+ predicate hasNoCompatibleNonBlanketTarget (
22002190 AssocFunctionCall afc , FunctionPosition selfPos , DerefChain derefChain , BorrowKind borrow
22012191 ) {
2202- hasNoCompatibleNonBlanketLikeTargetCheck ( afc , selfPos , derefChain , borrow ) and
2192+ hasNoCompatibleNonBlanketLikeTarget ( afc , selfPos , derefChain , borrow ) and
22032193 forall ( ImplItemNode i |
22042194 blanketLikeCandidate ( afc , selfPos , i , _, _, _) and
22052195 not i .isBlanketImplementation ( )
0 commit comments