@@ -7,6 +7,7 @@ private import Type as T
77private import TypeMention
88private import codeql.typeinference.internal.TypeInference
99private import codeql.rust.frameworks.stdlib.Stdlib
10+ private import codeql.rust.frameworks.stdlib.Bultins as Builtins
1011
1112class Type = T:: Type ;
1213
@@ -190,6 +191,21 @@ private Type inferAnnotatedType(AstNode n, TypePath path) {
190191 result = getTypeAnnotation ( n ) .resolveTypeAt ( path )
191192}
192193
194+ private Type inferLogicalOperationType ( AstNode n , TypePath path ) {
195+ exists ( Builtins:: BuiltinType t , BinaryLogicalOperation be |
196+ n = [ be , be .getLhs ( ) , be .getRhs ( ) ] and
197+ path .isEmpty ( ) and
198+ result = TStruct ( t ) and
199+ t instanceof Builtins:: Bool
200+ )
201+ }
202+
203+ private Type inferAssignmentOperationType ( AstNode n , TypePath path ) {
204+ n instanceof AssignmentOperation and
205+ path .isEmpty ( ) and
206+ result = TUnit ( )
207+ }
208+
193209/**
194210 * Holds if the type of `n1` at `path1` is the same as the type of `n2` at
195211 * `path2` and type information should propagate in both directions through the
@@ -237,6 +253,12 @@ private predicate typeEquality(AstNode n1, TypePath path1, AstNode n2, TypePath
237253 break .getTarget ( ) = n2 .( LoopExpr ) and
238254 path1 = path2
239255 )
256+ or
257+ exists ( AssignmentExpr be |
258+ n1 = be .getLhs ( ) and
259+ n2 = be .getRhs ( ) and
260+ path1 = path2
261+ )
240262}
241263
242264pragma [ nomagic]
@@ -932,8 +954,6 @@ private Type inferTryExprType(TryExpr te, TypePath path) {
932954 )
933955}
934956
935- private import codeql.rust.frameworks.stdlib.Bultins as Builtins
936-
937957pragma [ nomagic]
938958private StructType inferLiteralType ( LiteralExpr le ) {
939959 exists ( Builtins:: BuiltinType t | result = TStruct ( t ) |
@@ -1156,6 +1176,10 @@ private module Cached {
11561176 Stages:: TypeInferenceStage:: ref ( ) and
11571177 result = inferAnnotatedType ( n , path )
11581178 or
1179+ result = inferLogicalOperationType ( n , path )
1180+ or
1181+ result = inferAssignmentOperationType ( n , path )
1182+ or
11591183 result = inferTypeEquality ( n , path )
11601184 or
11611185 result = inferImplicitSelfType ( n , path )
0 commit comments