Skip to content

Commit 7050100

Browse files
authored
Merge pull request github#18232 from paldepind/rust-self-capture
Rust: Fix a bug where captured `self` parameters where not considered captured
2 parents 8a6c529 + 9b34615 commit 7050100

File tree

5 files changed

+349
-282
lines changed

5 files changed

+349
-282
lines changed

rust/ql/lib/codeql/rust/elements/internal/VariableImpl.qll

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ module Impl {
139139
*/
140140
IdentPat getPat() { variableDecl(definingNode, result, name) }
141141

142+
/** Gets the enclosing CFG scope for this variable declaration. */
143+
CfgScope getEnclosingCfgScope() { result = definingNode.getEnclosingCfgScope() }
144+
142145
/** Gets the `let` statement that introduces this variable, if any. */
143146
LetStmt getLetStmt() { this.getPat() = result.getPat() }
144147

@@ -452,7 +455,7 @@ module Impl {
452455
Variable getVariable() { result = v }
453456

454457
/** Holds if this access is a capture. */
455-
predicate isCapture() { this.getEnclosingCfgScope() != v.getPat().getEnclosingCfgScope() }
458+
predicate isCapture() { this.getEnclosingCfgScope() != v.getEnclosingCfgScope() }
456459

457460
override string toString() { result = name }
458461

0 commit comments

Comments
 (0)