@@ -312,6 +312,18 @@ private module Input3 implements InputSig3 {
312312
313313 class Expr = Rust:: Expr ;
314314
315+ class SwitchExpr extends Rust:: MatchExpr {
316+ Expr getExpr ( ) { result = this .getScrutinee ( ) }
317+
318+ Case getCase ( int index ) { result = this .getArm ( index ) }
319+ }
320+
321+ class Case extends Rust:: MatchArm {
322+ AstNode getAPattern ( ) { result = this .getPat ( ) }
323+
324+ Expr getBody ( ) { result = this .getExpr ( ) }
325+ }
326+
315327 class ConditionalExpr extends IfExpr {
316328 Expr getThen ( ) { result = super .getThen ( ) }
317329 }
@@ -447,7 +459,46 @@ private module Input3 implements InputSig3 {
447459 )
448460 }
449461
450- predicate inferCertainTypeInput = CertainTypeInferenceInput:: inferCertainTypeInput / 2 ;
462+ Type inferCertainTypeInput ( AstNode n , TypePath path ) {
463+ result = inferFunctionBodyType ( n , path )
464+ or
465+ result = inferLiteralType ( n , path , true )
466+ or
467+ result = inferRefPatType ( n ) and
468+ path .isEmpty ( )
469+ or
470+ result = inferRefExprType ( n ) and
471+ path .isEmpty ( )
472+ or
473+ result = inferCertainStructExprType ( n , path )
474+ or
475+ result = inferCertainStructPatType ( n , path )
476+ or
477+ result = inferRangeExprType ( n ) and
478+ path .isEmpty ( )
479+ or
480+ result = inferTupleRootType ( n ) and
481+ path .isEmpty ( )
482+ or
483+ result = inferBlockExprType ( n , path )
484+ or
485+ result = inferArrayExprType ( n ) and
486+ path .isEmpty ( )
487+ or
488+ result = inferCastExprType ( n , path )
489+ or
490+ exprHasUnitType ( n ) and
491+ path .isEmpty ( ) and
492+ result instanceof UnitType
493+ or
494+ isPanicMacroCall ( n ) and
495+ path .isEmpty ( ) and
496+ result instanceof NeverType
497+ or
498+ n instanceof ClosureExpr and
499+ path .isEmpty ( ) and
500+ result = closureRootType ( )
501+ }
451502
452503 predicate typeEqualityInput ( AstNode n1 , TypePath prefix1 , AstNode n2 , TypePath prefix2 ) {
453504 prefix1 .isEmpty ( ) and
@@ -828,60 +879,12 @@ private TypePath closureParameterPath(int arity, int index) {
828879 TypePath:: singleton ( getTupleTypeParameter ( arity , index ) ) )
829880}
830881
831- /** Module for inferring certain type information. */
832- private module CertainTypeInferenceInput {
833- private Type inferCertainStructExprType ( StructExpr se , TypePath path ) {
834- result = se .getPath ( ) .( TypeMention ) .getTypeAt ( path )
835- }
836-
837- private Type inferCertainStructPatType ( StructPat sp , TypePath path ) {
838- result = sp .getPath ( ) .( TypeMention ) .getTypeAt ( path )
839- }
882+ private Type inferCertainStructExprType ( StructExpr se , TypePath path ) {
883+ result = se .getPath ( ) .( TypeMention ) .getTypeAt ( path )
884+ }
840885
841- /**
842- * Holds if `n` has complete and certain type information and if `n` has the
843- * resulting type at `path`.
844- */
845- Type inferCertainTypeInput ( AstNode n , TypePath path ) {
846- result = inferFunctionBodyType ( n , path )
847- or
848- result = inferLiteralType ( n , path , true )
849- or
850- result = inferRefPatType ( n ) and
851- path .isEmpty ( )
852- or
853- result = inferRefExprType ( n ) and
854- path .isEmpty ( )
855- or
856- result = inferCertainStructExprType ( n , path )
857- or
858- result = inferCertainStructPatType ( n , path )
859- or
860- result = inferRangeExprType ( n ) and
861- path .isEmpty ( )
862- or
863- result = inferTupleRootType ( n ) and
864- path .isEmpty ( )
865- or
866- result = inferBlockExprType ( n , path )
867- or
868- result = inferArrayExprType ( n ) and
869- path .isEmpty ( )
870- or
871- result = inferCastExprType ( n , path )
872- or
873- exprHasUnitType ( n ) and
874- path .isEmpty ( ) and
875- result instanceof UnitType
876- or
877- isPanicMacroCall ( n ) and
878- path .isEmpty ( ) and
879- result instanceof NeverType
880- or
881- n instanceof ClosureExpr and
882- path .isEmpty ( ) and
883- result = closureRootType ( )
884- }
886+ private Type inferCertainStructPatType ( StructPat sp , TypePath path ) {
887+ result = sp .getPath ( ) .( TypeMention ) .getTypeAt ( path )
885888}
886889
887890private Type inferAssignmentOperationType ( AstNode n , TypePath path ) {
0 commit comments