mirror of
https://github.com/github/codeql.git
synced 2026-04-26 01:05:15 +02:00
Merge pull request #18754 from paldepind/rust-ref-pattern
Rust ref pattern
This commit is contained in:
@@ -22,4 +22,4 @@ where
|
||||
not isUnused(v) and
|
||||
not v instanceof DiscardVariable and
|
||||
not write.isInMacroExpansion()
|
||||
select write, "Variable $@ is assigned a value that is never used.", v, v.getName()
|
||||
select write, "Variable $@ is assigned a value that is never used.", v, v.getText()
|
||||
|
||||
@@ -4,7 +4,7 @@ import rust
|
||||
* A deliberately unused variable, for example `_` or `_x`.
|
||||
*/
|
||||
class DiscardVariable extends Variable {
|
||||
DiscardVariable() { this.getName().charAt(0) = "_" }
|
||||
DiscardVariable() { this.getText().charAt(0) = "_" }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -25,5 +25,5 @@ predicate isAllowableUnused(Variable v) {
|
||||
v.getPat().isInMacroExpansion()
|
||||
or
|
||||
// a 'self' variable
|
||||
v.getName() = "self"
|
||||
v.getText() = "self"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user