@@ -981,93 +981,36 @@ private AssociatedTypeTypeParameter getFutureOutputTypeParameter() {
981981 result .getTypeAlias ( ) = any ( FutureTrait ft ) .getOutputType ( )
982982}
983983
984- /**
985- * A matching configuration for resolving types of `.await` expressions.
986- */
987- private module AwaitExprMatchingInput implements MatchingInputSig {
988- private newtype TDeclarationPosition =
989- TSelfDeclarationPosition ( ) or
990- TOutputPos ( )
991-
992- class DeclarationPosition extends TDeclarationPosition {
993- predicate isSelf ( ) { this = TSelfDeclarationPosition ( ) }
994-
995- predicate isOutput ( ) { this = TOutputPos ( ) }
996-
997- string toString ( ) {
998- this .isSelf ( ) and
999- result = "self"
1000- or
1001- this .isOutput ( ) and
1002- result = "(output)"
1003- }
1004- }
1005-
1006- private class BuiltinsAwaitFile extends File {
1007- BuiltinsAwaitFile ( ) {
1008- this .getBaseName ( ) = "await.rs" and
1009- this .getParentContainer ( ) instanceof Builtins:: BuiltinsFolder
1010- }
1011- }
1012-
1013- class Declaration extends Function {
1014- Declaration ( ) {
1015- this .getFile ( ) instanceof BuiltinsAwaitFile and
1016- this .getName ( ) .getText ( ) = "await_type_matching"
1017- }
1018-
1019- TypeParameter getTypeParameter ( TypeParameterPosition ppos ) {
1020- typeParamMatchPosition ( this .getGenericParamList ( ) .getATypeParam ( ) , result , ppos )
1021- }
1022-
1023- Type getDeclaredType ( DeclarationPosition dpos , TypePath path ) {
1024- dpos .isSelf ( ) and
1025- result = this .getParam ( 0 ) .getTypeRepr ( ) .( TypeMention ) .resolveTypeAt ( path )
1026- or
1027- dpos .isOutput ( ) and
1028- result = this .getRetType ( ) .getTypeRepr ( ) .( TypeMention ) .resolveTypeAt ( path )
1029- }
1030- }
1031-
1032- class AccessPosition = DeclarationPosition ;
1033-
1034- class Access extends AwaitExpr {
1035- Type getTypeArgument ( TypeArgumentPosition apos , TypePath path ) { none ( ) }
1036-
1037- AstNode getNodeAt ( AccessPosition apos ) {
1038- result = this .getExpr ( ) and
1039- apos .isSelf ( )
1040- or
1041- result = this and
1042- apos .isOutput ( )
1043- }
1044-
1045- Type getInferredType ( AccessPosition apos , TypePath path ) {
1046- result = inferType ( this .getNodeAt ( apos ) , path )
1047- }
1048-
1049- Declaration getTarget ( ) { exists ( this ) and exists ( result ) }
1050- }
1051-
1052- predicate accessDeclarationPositionMatch ( AccessPosition apos , DeclarationPosition dpos ) {
1053- apos = dpos
1054- }
1055- }
1056-
1057984pragma [ nomagic]
1058985private TraitType inferAsyncBlockExprRootType ( AsyncBlockExpr abe ) {
1059986 // `typeEquality` handles the non-root case
1060987 exists ( abe ) and
1061988 result = getFutureTraitType ( )
1062989}
1063990
1064- private module AwaitExprMatching = Matching< AwaitExprMatchingInput > ;
991+ final class AwaitTarget extends Expr {
992+ AwaitTarget ( ) { this = any ( AwaitExpr ae ) .getExpr ( ) }
993+
994+ Type getTypeAt ( TypePath path ) { result = inferType ( this , path ) }
995+ }
996+
997+ private module AwaitSatisfiesConstraintInput implements SatisfiesConstraintSig< AwaitTarget > {
998+ predicate relevantConstraint ( AwaitTarget term , Type constraint ) {
999+ exists ( term ) and
1000+ constraint .( TraitType ) .getTrait ( ) instanceof FutureTrait
1001+ }
1002+ }
1003+
1004+ predicate awaitSatisfiesConstraintTypeMention ( AwaitTarget at , Type constraint , TypePath path , Type t ) {
1005+ SatisfiesConstraint< AwaitTarget , AwaitSatisfiesConstraintInput > :: satisfiesConstraintTypeMention ( at ,
1006+ constraint , path , t )
1007+ }
10651008
10661009pragma [ nomagic]
10671010private Type inferAwaitExprType ( AstNode n , TypePath path ) {
1068- exists ( AwaitExprMatchingInput :: Access a , AwaitExprMatchingInput :: AccessPosition apos |
1069- n = a . getNodeAt ( apos ) and
1070- result = AwaitExprMatching :: inferAccessType ( a , apos , path )
1011+ exists ( TypePath exprPath |
1012+ awaitSatisfiesConstraintTypeMention ( n . ( AwaitExpr ) . getExpr ( ) , _ , exprPath , result ) and
1013+ exprPath . isCons ( getFutureOutputTypeParameter ( ) , path )
10711014 )
10721015 or
10731016 // This case is needed for `async` functions and blocks, where we assign
0 commit comments