@@ -134,7 +134,7 @@ 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
140140 class TypeMention = TM:: TypeMention ;
@@ -162,7 +162,7 @@ private module Input2 implements InputSig2 {
162162 * inference module for more information.
163163 */
164164 predicate conditionSatisfiesConstraint (
165- TypeAbstraction abs , TypeMention condition , TypeMention constraint , boolean transitive
165+ TypeAbstraction abs , PreTypeMention condition , PreTypeMention constraint , boolean transitive
166166 ) {
167167 // `impl` blocks implementing traits
168168 transitive = false and
@@ -212,7 +212,7 @@ private module Input2 implements InputSig2 {
212212 }
213213}
214214
215- private module M2 = Make2< Input2 > ;
215+ private module M2 = Make2< PreTypeMention , Input2 > ;
216216
217217import M2
218218
@@ -236,6 +236,27 @@ module Consistency {
236236 }
237237}
238238
239+ signature predicate relevantTraitSig ( AstNode n , Trait t ) ;
240+
241+ module TermSatisfiesTrait< relevantTraitSig / 2 relevantTrait> {
242+ private class RelevantTerm extends AstNode {
243+ RelevantTerm ( ) { relevantTrait ( this , _) }
244+
245+ Type getTypeAt ( TypePath path ) { result = inferType ( this , path ) }
246+ }
247+
248+ private module MethodCallSatisfiesDerefConstraintInput implements
249+ SatisfiesConstraintInputSig< RelevantTerm >
250+ {
251+ pragma [ nomagic]
252+ predicate relevantConstraint ( RelevantTerm term , Type constraint ) {
253+ relevantTrait ( term , constraint .( TraitType ) .getTrait ( ) )
254+ }
255+
256+ predicate useUniversalConditions ( ) { none ( ) }
257+ }
258+ }
259+
239260/** A function without a `self` parameter. */
240261private class NonMethodFunction extends Function {
241262 NonMethodFunction ( ) { not this .hasSelfParam ( ) }
@@ -382,7 +403,7 @@ pragma[nomagic]
382403private Type inferAnnotatedType ( AstNode n , TypePath path ) {
383404 result = getTypeAnnotation ( n ) .resolveTypeAt ( path )
384405 or
385- result = n .( ShorthandSelfParameterMention ) .resolveTypeAt ( path )
406+ result = n .( SelfParam ) . ( TypeMention ) .resolveTypeAt ( path )
386407}
387408
388409pragma [ nomagic]
@@ -3770,12 +3791,12 @@ private module ForIterableSatisfiesConstraintInput implements
37703791
37713792pragma [ nomagic]
37723793private AssociatedTypeTypeParameter getIteratorItemTypeParameter ( ) {
3773- result . getTypeAlias ( ) = any ( IteratorTrait t ) .getItemType ( )
3794+ result = getAssociatedTypeTypeParameter ( any ( IteratorTrait t ) .getItemType ( ) )
37743795}
37753796
37763797pragma [ nomagic]
37773798private AssociatedTypeTypeParameter getIntoIteratorItemTypeParameter ( ) {
3778- result . getTypeAlias ( ) = any ( IntoIteratorTrait t ) .getItemType ( )
3799+ result = getAssociatedTypeTypeParameter ( any ( IntoIteratorTrait t ) .getItemType ( ) )
37793800}
37803801
37813802pragma [ nomagic]
@@ -4084,12 +4105,14 @@ import Cached
40844105Type inferType ( AstNode n ) { result = inferType ( n , TypePath:: nil ( ) ) }
40854106
40864107/** Provides predicates for debugging the type inference implementation. */
4087- private module Debug {
4108+ module Debug {
40884109 Locatable getRelevantLocatable ( ) {
40894110 exists ( string filepath , int startline , int startcolumn , int endline , int endcolumn |
40904111 result .getLocation ( ) .hasLocationInfo ( filepath , startline , startcolumn , endline , endcolumn ) and
4091- filepath .matches ( "%/sqlx.rs" ) and
4092- startline = [ 56 .. 60 ]
4112+ filepath .matches ( "%/associated_types.rs" ) //and
4113+ // startline = [340]
4114+ // startline = 20
4115+ // startline = [120 .. 125]
40934116 )
40944117 }
40954118
@@ -4110,9 +4133,9 @@ private module Debug {
41104133 Input2:: conditionSatisfiesConstraint ( abs , condition , constraint , transitive )
41114134 }
41124135
4113- predicate debugInferShorthandSelfType ( ShorthandSelfParameterMention self , TypePath path , Type t ) {
4136+ predicate debugInferShorthandSelfType ( SelfParam self , TypePath path , Type t ) {
41144137 self = getRelevantLocatable ( ) and
4115- t = self .resolveTypeAt ( path )
4138+ t = self .( TypeMention ) . resolveTypeAt ( path )
41164139 }
41174140
41184141 predicate debugInferMethodCallType ( AstNode n , TypePath path , Type t ) {
0 commit comments