Skip to content

Commit c160a1f

Browse files
committed
Rust: Fix common FPs for rust/unused-variable and rust/unused-value.
1 parent 4a1abc7 commit c160a1f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

rust/ql/src/queries/unusedentities/UnusedVariable.qll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,8 @@ predicate isAllowableUnused(Variable v) {
4343
or
4444
// a 'self' variable
4545
v.getText() = "self"
46+
or
47+
// a common source of false positives is match arms that are misrecognized as
48+
// a variable, having not been correctly resolved
49+
v.getPat().getParentNode() instanceof MatchArm
4650
}

0 commit comments

Comments
 (0)