File tree Expand file tree Collapse file tree 4 files changed +11
-12
lines changed
lib/codeql/rust/elements/internal
query-tests/unusedentities Expand file tree Collapse file tree 4 files changed +11
-12
lines changed Original file line number Diff line number Diff line change @@ -78,7 +78,12 @@ module Impl {
78
78
not exists ( getOutermostEnclosingOrPat ( p ) ) and
79
79
definingNode = p .getName ( )
80
80
) and
81
- name = p .getName ( ) .getText ( )
81
+ name = p .getName ( ) .getText ( ) and
82
+ // exclude for now anything starting with an uppercase character, which may be a reference to
83
+ // an enum constant (e.g. `None`). This excludes static and constant variables (UPPERCASE),
84
+ // which we don't appear to recognize yet anyway. This also assumes programmers follow the
85
+ // naming guidelines, which they generally do, but they're not enforced.
86
+ not name .charAt ( 0 ) .isUppercase ( )
82
87
}
83
88
84
89
/** A variable. */
Original file line number Diff line number Diff line change @@ -24,7 +24,6 @@ variable
24
24
| variables.rs:100:9:100:10 | x6 |
25
25
| variables.rs:101:9:101:10 | y1 |
26
26
| variables.rs:105:14:105:15 | y1 |
27
- | variables.rs:110:9:110:12 | None |
28
27
| variables.rs:117:9:117:15 | numbers |
29
28
| variables.rs:121:13:121:17 | first |
30
29
| variables.rs:122:13:122:17 | third |
Original file line number Diff line number Diff line change 8
8
| main.rs:202:17:202:17 | a | Variable is not used. |
9
9
| main.rs:210:20:210:22 | val | Variable is not used. |
10
10
| main.rs:223:14:223:16 | val | Variable is not used. |
11
- | main.rs:225:9:225:12 | None | Variable is not used. |
12
- | main.rs:234:9:234:12 | None | Variable is not used. |
13
11
| main.rs:240:22:240:24 | val | Variable is not used. |
14
12
| main.rs:248:24:248:26 | val | Variable is not used. |
15
13
| main.rs:257:13:257:15 | num | Variable is not used. |
16
- | main.rs:268:9:268:11 | Yes | Variable is not used. |
17
- | main.rs:269:9:269:10 | No | Variable is not used. |
18
14
| main.rs:272:12:272:12 | j | Variable is not used. |
19
- | main.rs:282:12:282:14 | Yes | Variable is not used. |
20
15
| main.rs:294:25:294:25 | y | Variable is not used. |
21
16
| main.rs:298:28:298:28 | a | Variable is not used. |
22
17
| main.rs:302:9:302:9 | p | Variable is not used. |
Original file line number Diff line number Diff line change @@ -222,7 +222,7 @@ fn if_lets_matches() {
222
222
match c {
223
223
Some ( val) => { // BAD: unused variable
224
224
}
225
- None => { // SPURIOUS: unused variable 'None'
225
+ None => {
226
226
}
227
227
}
228
228
@@ -231,7 +231,7 @@ fn if_lets_matches() {
231
231
Some ( val) => {
232
232
total += val;
233
233
}
234
- None => { // SPURIOUS: unused variable 'None'
234
+ None => {
235
235
}
236
236
}
237
237
@@ -265,8 +265,8 @@ fn if_lets_matches() {
265
265
266
266
let i = Yes ;
267
267
match i {
268
- Yes => { } // SPURIOUS: unused variable 'Yes'
269
- No => { } // SPURIOUS: unused variable 'No'
268
+ Yes => { }
269
+ No => { }
270
270
}
271
271
272
272
if let j = Yes { // BAD: unused variable
@@ -279,7 +279,7 @@ fn if_lets_matches() {
279
279
}
280
280
281
281
let l = Yes ;
282
- if let Yes = l { // SPURIOUS: unused variable 'Yes'
282
+ if let Yes = l {
283
283
}
284
284
285
285
match 1 {
You can’t perform that action at this time.
0 commit comments