@@ -887,37 +887,32 @@ private Type inferTryExprType(TryExpr te, TypePath path) {
887887
888888private import codeql.rust.frameworks.stdlib.Bultins as Builtins
889889
890- pragma [ nomagic]
891- StructType getBuiltinType ( string name ) {
892- result = TStruct ( any ( Builtins:: BuiltinType t | name = t .getName ( ) ) )
893- }
894-
895890pragma [ nomagic]
896891private StructType inferLiteralType ( LiteralExpr le ) {
897- le instanceof CharLiteralExpr and
898- result = TStruct ( any ( Builtins :: Char t ) )
899- or
900- le instanceof StringLiteralExpr and
901- result = TStruct ( any ( Builtins :: Str t ) )
902- or
903- le =
904- any ( IntegerLiteralExpr n |
905- not exists ( n . getSuffix ( ) ) and
906- result = getBuiltinType ( "i32" )
907- or
908- result = getBuiltinType ( n .getSuffix ( ) )
909- )
910- or
911- le =
912- any ( FloatLiteralExpr n |
913- not exists ( n . getSuffix ( ) ) and
914- result = getBuiltinType ( "f32" )
915- or
916- result = getBuiltinType ( n . getSuffix ( ) )
917- )
918- or
919- le instanceof BooleanLiteralExpr and
920- result = TStruct ( any ( Builtins :: Bool t ) )
892+ exists ( Builtins :: BuiltinType t | result = TStruct ( t ) |
893+ le instanceof CharLiteralExpr and
894+ t instanceof Builtins :: Char
895+ or
896+ le instanceof StringLiteralExpr and
897+ t instanceof Builtins :: Str
898+ or
899+ le =
900+ any ( NumberLiteralExpr ne |
901+ t . getName ( ) = ne . getSuffix ( )
902+ or
903+ not exists ( ne .getSuffix ( ) ) and
904+ (
905+ ne instanceof IntegerLiteralExpr and
906+ t instanceof Builtins :: I32
907+ or
908+ ne instanceof FloatLiteralExpr and
909+ t instanceof Builtins :: F64
910+ )
911+ )
912+ or
913+ le instanceof BooleanLiteralExpr and
914+ t instanceof Builtins :: Bool
915+ )
921916}
922917
923918cached
0 commit comments