We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 949cfc3 + 01f9b42 commit 93e8534Copy full SHA for 93e8534
rust/ql/src/change-notes/2025-12-10-unused-variable.md
@@ -0,0 +1,4 @@
1
+---
2
+category: minorAnalysis
3
4
+* Fixed common false positives for the `rust/unused-variable` and `rust/unused-value` queries.
rust/ql/src/queries/unusedentities/UnusedVariable.qll
@@ -43,4 +43,10 @@ predicate isAllowableUnused(Variable v) {
43
or
44
// a 'self' variable
45
v.getText() = "self"
46
+ or
47
+ // a common source of false positives is match arms containing constants
48
+ // (typically beginning with a capital letter) that are misrecognized as a
49
+ // variable, having not been correctly resolved.
50
+ v.getPat().getParentNode() instanceof MatchArm and
51
+ v.getText().charAt(0).isUppercase()
52
}
0 commit comments