@@ -134,15 +134,13 @@ class TypePath = M1::TypePath;
134134
135135module TypePath = M1:: TypePath;
136136
137- private module Input2 implements InputSig2 {
137+ private module Input2 implements InputSig2< PreTypeMention > {
138138 private import TypeMention as TM
139139
140- class TypeMention = TM:: TypeMention ;
141-
142- TypeMention getABaseTypeMention ( Type t ) { none ( ) }
140+ PreTypeMention getABaseTypeMention ( Type t ) { none ( ) }
143141
144142 Type getATypeParameterConstraint ( TypeParameter tp , TypePath path ) {
145- exists ( TypeMention tm | result = tm .resolveTypeAt ( path ) |
143+ exists ( TypeMention tm | result = tm .getTypeAt ( path ) |
146144 tm = tp .( TypeParamTypeParameter ) .getTypeParam ( ) .getATypeBound ( ) .getTypeRepr ( ) or
147145 tm = tp .( SelfTypeParameter ) .getTrait ( ) or
148146 tm =
@@ -162,7 +160,7 @@ private module Input2 implements InputSig2 {
162160 * inference module for more information.
163161 */
164162 predicate conditionSatisfiesConstraint (
165- TypeAbstraction abs , TypeMention condition , TypeMention constraint , boolean transitive
163+ TypeAbstraction abs , PreTypeMention condition , PreTypeMention constraint , boolean transitive
166164 ) {
167165 // `impl` blocks implementing traits
168166 transitive = false and
@@ -212,7 +210,7 @@ private module Input2 implements InputSig2 {
212210 }
213211}
214212
215- private module M2 = Make2< Input2 > ;
213+ private module M2 = Make2< PreTypeMention , Input2 > ;
216214
217215import M2
218216
@@ -236,6 +234,25 @@ module Consistency {
236234 }
237235}
238236
237+ signature predicate relevantTraitSig ( AstNode n , Trait t ) ;
238+
239+ module TermSatisfiesTrait< relevantTraitSig / 2 relevantTrait> {
240+ private class RelevantTerm extends AstNode {
241+ RelevantTerm ( ) { relevantTrait ( this , _) }
242+
243+ Type getTypeAt ( TypePath path ) { result = inferType ( this , path ) }
244+ }
245+
246+ private module MethodCallSatisfiesDerefConstraintInput implements
247+ SatisfiesConstraintInputSig< RelevantTerm >
248+ {
249+ pragma [ nomagic]
250+ predicate relevantConstraint ( RelevantTerm term , Type constraint ) {
251+ relevantTrait ( term , constraint .( TraitType ) .getTrait ( ) )
252+ }
253+ }
254+ }
255+
239256/** A function without a `self` parameter. */
240257private class NonMethodFunction extends Function {
241258 NonMethodFunction ( ) { not this .hasSelfParam ( ) }
@@ -382,7 +399,7 @@ pragma[nomagic]
382399private Type inferAnnotatedType ( AstNode n , TypePath path ) {
383400 result = getTypeAnnotation ( n ) .resolveTypeAt ( path )
384401 or
385- result = n .( ShorthandSelfParameterMention ) .resolveTypeAt ( path )
402+ result = n .( SelfParam ) . ( TypeMention ) .resolveTypeAt ( path )
386403}
387404
388405pragma [ nomagic]
@@ -2330,19 +2347,19 @@ private module MethodResolution {
23302347 * instance of the type being implemented.
23312348 */
23322349 private module TypeQualifierIsInstantiationOfImplSelfInput implements
2333- IsInstantiationOfInputSig< MethodCallCallExpr , TypeMentionTypeTree >
2350+ IsInstantiationOfInputSig< MethodCallCallExpr , TypeMention >
23342351 {
23352352 pragma [ nomagic]
23362353 private predicate potentialInstantiationOf0 (
2337- MethodCallCallExpr ce , ImplItemNode impl , TypeMentionTypeTree constraint
2354+ MethodCallCallExpr ce , ImplItemNode impl , TypeMention constraint
23382355 ) {
23392356 ce .hasTypeQualifiedCandidate ( impl ) and
23402357 constraint = impl .getSelfPath ( )
23412358 }
23422359
23432360 pragma [ nomagic]
23442361 predicate potentialInstantiationOf (
2345- MethodCallCallExpr ce , TypeAbstraction abs , TypeMentionTypeTree constraint
2362+ MethodCallCallExpr ce , TypeAbstraction abs , TypeMention constraint
23462363 ) {
23472364 potentialInstantiationOf0 ( ce , abs , constraint ) and
23482365 if abs .( Impl ) .hasTrait ( )
@@ -2353,14 +2370,13 @@ private module MethodResolution {
23532370 else any ( )
23542371 }
23552372
2356- predicate relevantConstraint ( TypeMentionTypeTree constraint ) {
2373+ predicate relevantConstraint ( TypeMention constraint ) {
23572374 potentialInstantiationOf0 ( _, _, constraint )
23582375 }
23592376 }
23602377
23612378 private module TypeQualifierIsInstantiationOfImplSelf =
2362- IsInstantiationOf< MethodCallCallExpr , TypeMentionTypeTree ,
2363- TypeQualifierIsInstantiationOfImplSelfInput > ;
2379+ IsInstantiationOf< MethodCallCallExpr , TypeMention , TypeQualifierIsInstantiationOfImplSelfInput > ;
23642380
23652381 /**
23662382 * A configuration for anti-matching the type of a receiver against the type of
@@ -4138,8 +4154,8 @@ private module Debug {
41384154 Locatable getRelevantLocatable ( ) {
41394155 exists ( string filepath , int startline , int startcolumn , int endline , int endcolumn |
41404156 result .getLocation ( ) .hasLocationInfo ( filepath , startline , startcolumn , endline , endcolumn ) and
4141- filepath .matches ( "%/sqlx .rs" ) and
4142- startline = [ 56 .. 60 ]
4157+ filepath .matches ( "%/algorithm/mod .rs" ) and
4158+ startline = [ 300 .. 303 ]
41434159 )
41444160 }
41454161
@@ -4160,9 +4176,9 @@ private module Debug {
41604176 Input2:: conditionSatisfiesConstraint ( abs , condition , constraint , transitive )
41614177 }
41624178
4163- predicate debugInferShorthandSelfType ( ShorthandSelfParameterMention self , TypePath path , Type t ) {
4179+ predicate debugInferShorthandSelfType ( SelfParam self , TypePath path , Type t ) {
41644180 self = getRelevantLocatable ( ) and
4165- t = self .resolveTypeAt ( path )
4181+ t = self .( TypeMention ) . resolveTypeAt ( path )
41664182 }
41674183
41684184 predicate debugInferMethodCallType ( AstNode n , TypePath path , Type t ) {
0 commit comments