-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17655 from hvitved/rust/variable-mut
Rust: `&(mut) x` is neither a read nor a write
- Loading branch information
Showing
7 changed files
with
1,154 additions
and
965 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** Provides classes for assignment operations. */ | ||
|
||
private import rust | ||
private import codeql.rust.elements.internal.BinaryExprImpl | ||
|
||
/** An assignment operation. */ | ||
abstract private class AssignmentOperationImpl extends Impl::BinaryExpr { } | ||
|
||
final class AssignmentOperation = AssignmentOperationImpl; | ||
|
||
/** | ||
* An assignment expression, for example | ||
* | ||
* ```rust | ||
* x = y; | ||
* ``` | ||
*/ | ||
final class AssignmentExpr extends AssignmentOperationImpl { | ||
AssignmentExpr() { this.getOperatorName() = "=" } | ||
|
||
override string getAPrimaryQlClass() { result = "AssignmentExpr" } | ||
} | ||
|
||
/** | ||
* A compound assignment expression, for example | ||
* | ||
* ```rust | ||
* x += y; | ||
* ``` | ||
* | ||
* Note that compound assignment expressions are syntatic sugar for | ||
* trait invocations, i.e., the above actually means | ||
* | ||
* ```rust | ||
* (&mut x).add_assign(y); | ||
* ``` | ||
*/ | ||
final class CompoundAssignmentExpr extends AssignmentOperationImpl { | ||
private string operator; | ||
|
||
CompoundAssignmentExpr() { | ||
this.getOperatorName().regexpCapture("(\\+|-|\\*|/|%|&|\\||\\^|<<|>>)=", 1) = operator | ||
} | ||
|
||
/** | ||
* Gets the operator of this compound assignment expression. | ||
*/ | ||
string getOperator() { result = operator } | ||
|
||
override string getAPrimaryQlClass() { result = "CompoundAssignmentExpr" } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1,291 changes: 683 additions & 608 deletions
1,291
rust/ql/test/library-tests/variables/Cfg.expected
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.