Skip to content

Commit 68552f9

Browse files
authored
Merge pull request #20845 from hvitved/rust/cache-infer-certain-type
Rust: Cache `inferCertainType`
2 parents f4a6ba9 + 19ff5c0 commit 68552f9

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
@@ -419,9 +420,10 @@ module CertainTypeInference {
419420
* Holds if `n` has complete and certain type information and if `n` has the
420421
* resulting type at `path`.
421422
*/
422-
pragma[nomagic]
423+
cached
423424
Type inferCertainType(AstNode n, TypePath path) {
424-
result = inferAnnotatedType(n, path)
425+
result = inferAnnotatedType(n, path) and
426+
Stages::TypeInferenceStage::ref()
425427
or
426428
result = inferCertainCallExprType(n, path)
427429
or
@@ -3407,8 +3409,6 @@ private Type inferCastExprType(CastExpr ce, TypePath path) {
34073409

34083410
cached
34093411
private module Cached {
3410-
private import codeql.rust.internal.CachedStages
3411-
34123412
/** Holds if `receiver` is the receiver of a method call with an implicit dereference. */
34133413
cached
34143414
predicate receiverHasImplicitDeref(AstNode receiver) {

0 commit comments

Comments
 (0)