Skip to content

Commit 19ff5c0

Browse files
committed
Rust: Cache inferCertainType
Ideally, this shouldn't be needed, as we already cache `inferType`. However, since we have consistency checks that directly call `inferCertainType`, we need to cache it as well to avoid recomputation.
1 parent e986cca commit 19ff5c0

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ private import TypeMention
99
private import typeinference.FunctionType
1010
private import typeinference.FunctionOverloading as FunctionOverloading
1111
private import typeinference.BlanketImplementation as BlanketImplementation
12+
private import codeql.rust.internal.CachedStages
1213
private import codeql.typeinference.internal.TypeInference
1314
private import codeql.rust.frameworks.stdlib.Stdlib
1415
private import codeql.rust.frameworks.stdlib.Builtins as Builtins
@@ -437,9 +438,10 @@ module CertainTypeInference {
437438
* Holds if `n` has complete and certain type information and if `n` has the
438439
* resulting type at `path`.
439440
*/
440-
pragma[nomagic]
441+
cached
441442
Type inferCertainType(AstNode n, TypePath path) {
442-
result = inferAnnotatedType(n, path)
443+
result = inferAnnotatedType(n, path) and
444+
Stages::TypeInferenceStage::ref()
443445
or
444446
result = inferCertainCallExprType(n, path)
445447
or
@@ -3454,8 +3456,6 @@ private Type inferCastExprType(CastExpr ce, TypePath path) {
34543456

34553457
cached
34563458
private module Cached {
3457-
private import codeql.rust.internal.CachedStages
3458-
34593459
/** Holds if `receiver` is the receiver of a method call with an implicit dereference. */
34603460
cached
34613461
predicate receiverHasImplicitDeref(AstNode receiver) {

0 commit comments

Comments
 (0)