Rust: Fix captured variable data flow inconsistency

This commit is contained in:
Simon Friis Vindum
2024-12-12 16:28:19 +01:00
parent 16dcc5c278
commit 0fa40fcdcc
3 changed files with 7 additions and 10 deletions

View File

@@ -8,6 +8,7 @@ private import codeql.dataflow.DataFlow
private import codeql.dataflow.internal.DataFlowImpl
private import rust
private import SsaImpl as SsaImpl
private import codeql.rust.controlflow.internal.Scope as Scope
private import codeql.rust.controlflow.ControlFlowGraph
private import codeql.rust.controlflow.CfgNodes
private import codeql.rust.dataflow.Ssa
@@ -771,7 +772,12 @@ class LambdaCallKind = Unit;
/** Holds if `creation` is an expression that creates a lambda of kind `kind`. */
private predicate lambdaCreationExpr(Expr creation, LambdaCallKind kind) {
creation instanceof ClosureExpr and exists(kind)
(
creation instanceof ClosureExpr
or
creation instanceof Scope::AsyncBlockScope
) and
exists(kind)
}
/**

View File

@@ -1,5 +0,0 @@
variableAccessAstNesting
| test.rs:396:26:396:26 | b | test.rs:409:28:414:9 | { ... } | CapturedVariable access is not nested in the defining callable |
| test.rs:409:23:409:25 | foo | test.rs:409:28:414:9 | { ... } | CapturedVariable access is not nested in the defining callable |
consistencyOverview
| CapturedVariable access is not nested in the defining callable | 2 |

View File

@@ -1,4 +0,0 @@
variableAccessAstNesting
| variables.rs:436:13:436:13 | i | variables.rs:437:17:439:5 | { ... } | CapturedVariable access is not nested in the defining callable |
consistencyOverview
| CapturedVariable access is not nested in the defining callable | 1 |