🌐 AI搜索 & 代理 主页
Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Rust: Narrow the exclusion a little.
  • Loading branch information
geoffw0 committed Dec 11, 2025
commit d88bae9ec20df5e18dba21f7e07db0c63724b11f
8 changes: 5 additions & 3 deletions rust/ql/src/queries/unusedentities/UnusedVariable.qll
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ predicate isAllowableUnused(Variable v) {
// a 'self' variable
v.getText() = "self"
or
// a common source of false positives is match arms that are misrecognized as
// a variable, having not been correctly resolved
v.getPat().getParentNode() instanceof MatchArm
// 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()
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
| main.rs:307:13:307:15 | num | Variable 'num' is not used. |
| main.rs:342:25:342:25 | y | Variable 'y' is not used. |
| main.rs:345:28:345:28 | a | Variable 'a' is not used. |
| main.rs:348:9:348:9 | p | Variable 'p' is not used. |
| main.rs:366:9:366:13 | right | Variable 'right' is not used. |
| main.rs:372:9:372:14 | right2 | Variable 'right2' is not used. |
| main.rs:383:13:383:13 | y | Variable 'y' is not used. |
Expand Down
2 changes: 1 addition & 1 deletion rust/ql/test/query-tests/unusedentities/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ fn if_lets_matches() {
MyPoint { x: 3, y: a } => { // $ Alert[rust/unused-variable]
}
MyPoint { x: 4, .. } => {}
p => { // $ MISSING: Alert[rust/unused-variable]
p => { // $ Alert[rust/unused-variable]
}
}

Expand Down
Loading