Merge pull request #18754 from paldepind/rust-ref-pattern

Rust ref pattern
This commit is contained in:
Simon Friis Vindum
2025-02-19 14:24:09 +01:00
committed by GitHub
22 changed files with 867 additions and 296 deletions

View File

@@ -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()

View File

@@ -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"
}