File tree Expand file tree Collapse file tree 3 files changed +7
-4
lines changed
src/queries/unusedentities
test/query-tests/unusedentities Expand file tree Collapse file tree 3 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -44,7 +44,9 @@ predicate isAllowableUnused(Variable v) {
4444 // a 'self' variable
4545 v .getText ( ) = "self"
4646 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
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 ( )
5052}
Original file line number Diff line number Diff line change 1010| main.rs:307:13:307:15 | num | Variable 'num' is not used. |
1111| main.rs:342:25:342:25 | y | Variable 'y' is not used. |
1212| main.rs:345:28:345:28 | a | Variable 'a' is not used. |
13+ | main.rs:348:9:348:9 | p | Variable 'p' is not used. |
1314| main.rs:366:9:366:13 | right | Variable 'right' is not used. |
1415| main.rs:372:9:372:14 | right2 | Variable 'right2' is not used. |
1516| main.rs:383:13:383:13 | y | Variable 'y' is not used. |
Original file line number Diff line number Diff line change @@ -345,7 +345,7 @@ fn if_lets_matches() {
345345 MyPoint { x : 3 , y : a } => { // $ Alert[rust/unused-variable]
346346 }
347347 MyPoint { x : 4 , .. } => { }
348- p => { // $ MISSING: Alert[rust/unused-variable]
348+ p => { // $ Alert[rust/unused-variable]
349349 }
350350 }
351351
You can’t perform that action at this time.
0 commit comments