Skip to content

Commit 2f4e2d6

Browse files
committed
Rust: Infer certain types for logical operators
1 parent 0ff4dbc commit 2f4e2d6

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

rust/ql/lib/codeql/rust/internal/TypeInference.qll

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,8 @@ private module CertainTypeInference {
383383
result = inferRefNodeType(n) and
384384
path.isEmpty()
385385
or
386+
result = inferLogicalOperationType(n, path)
387+
or
386388
result = inferTupleRootType(n) and
387389
path.isEmpty()
388390
or
@@ -440,11 +442,10 @@ private module CertainTypeInference {
440442
}
441443

442444
private Type inferLogicalOperationType(AstNode n, TypePath path) {
443-
exists(Builtins::BuiltinType t, BinaryLogicalOperation be |
445+
exists(Builtins::Bool t, BinaryLogicalOperation be |
444446
n = [be, be.getLhs(), be.getRhs()] and
445447
path.isEmpty() and
446-
result = TStruct(t) and
447-
t instanceof Builtins::Bool
448+
result = TStruct(t)
448449
)
449450
}
450451

@@ -2381,8 +2382,6 @@ private module Cached {
23812382
(
23822383
result = inferAnnotatedType(n, path)
23832384
or
2384-
result = inferLogicalOperationType(n, path)
2385-
or
23862385
result = inferAssignmentOperationType(n, path)
23872386
or
23882387
result = inferTypeEquality(n, path)

0 commit comments

Comments
 (0)