Merge pull request #21009 from geoffw0/varfps

Rust: Fix some false positives for rust/unused-variable and rust/unused-value
This commit is contained in:
Geoffrey White
2025-12-15 09:48:47 +00:00
committed by GitHub
2 changed files with 10 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
---
category: minorAnalysis
---
* Fixed common false positives for the `rust/unused-variable` and `rust/unused-value` queries.

View File

@@ -43,4 +43,10 @@ predicate isAllowableUnused(Variable v) {
or or
// a 'self' variable // a 'self' variable
v.getText() = "self" v.getText() = "self"
or
// a common source of false positives is match arms containing constants
// (typically beginning with a capital letter) that are misrecognized as a
// variable, having not been correctly resolved.
v.getPat().getParentNode() instanceof MatchArm and
v.getText().charAt(0).isUppercase()
} }