mirror of
https://github.com/github/codeql.git
synced 2026-04-19 14:04:09 +02:00
Rust: SSA: restrict mutablyBorrowed to variables with a 'mut' modifier
This commit is contained in:
@@ -212,7 +212,8 @@ predicate capturedCallWrite(Expr call, BasicBlock bb, int i, Variable v) {
|
||||
/** Holds if `v` may be mutably borrowed in `e`. */
|
||||
private predicate mutablyBorrows(Expr e, Variable v) {
|
||||
e = any(MethodCallExpr mc).getReceiver() and
|
||||
e.(VariableAccess).getVariable() = v
|
||||
e.(VariableAccess).getVariable() = v and
|
||||
v.isMutable()
|
||||
or
|
||||
exists(RefExpr re | re = e and re.isMut() and re.getExpr().(VariableAccess).getVariable() = v)
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ module Impl {
|
||||
}
|
||||
|
||||
/** Hold is this variable is mutable. */
|
||||
predicate isMutable() { this.getPat().isMut() }
|
||||
predicate isMutable() { this.getPat().isMut() or this.getSelfParam().isMut() }
|
||||
|
||||
/** Hold is this variable is immutable. */
|
||||
predicate isImmutable() { not this.isMutable() }
|
||||
|
||||
Reference in New Issue
Block a user