File tree Expand file tree Collapse file tree 5 files changed +8
-9
lines changed
lib/codeql/rust/elements/internal
test/query-tests/unusedentities Expand file tree Collapse file tree 5 files changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -84,7 +84,10 @@ module Impl {
84
84
// an enum constant (e.g. `None`). This excludes static and constant variables (UPPERCASE),
85
85
// which we don't appear to recognize yet anyway. This also assumes programmers follow the
86
86
// naming guidelines, which they generally do, but they're not enforced.
87
- not name .charAt ( 0 ) .isUppercase ( )
87
+ not name .charAt ( 0 ) .isUppercase ( ) and
88
+ // exclude parameters from functions without a bodies as these are trait method declarations
89
+ // without implementations
90
+ not exists ( Function f | not f .hasBody ( ) and f .getParamList ( ) .getAParam ( ) .getPat ( ) = p )
88
91
}
89
92
90
93
/** A variable. */
Original file line number Diff line number Diff line change 19
19
| main.rs:370:9:370:9 | x | Variable is assigned a value that is never used. |
20
20
| main.rs:378:17:378:17 | x | Variable is assigned a value that is never used. |
21
21
| main.rs:432:9:432:10 | i6 | Variable is assigned a value that is never used. |
22
- | more.rs:4:23:4:25 | val | Variable is assigned a value that is never used. |
23
- | more.rs:8:19:8:21 | val | Variable is assigned a value that is never used. |
24
22
| more.rs:24:9:24:11 | val | Variable is assigned a value that is never used. |
25
23
| more.rs:46:9:46:14 | a_ptr4 | Variable is assigned a value that is never used. |
26
24
| more.rs:61:9:61:13 | d_ptr | Variable is assigned a value that is never used. |
Original file line number Diff line number Diff line change 18
18
| main.rs:379:21:379:21 | y | Variable is not used. |
19
19
| main.rs:427:27:427:29 | val | Variable is not used. |
20
20
| main.rs:430:22:430:24 | acc | Variable is not used. |
21
- | main.rs:442:9:442:13 | times | Variable is not used. |
22
- | main.rs:443:9:443:14 | unused | Variable is not used. |
23
21
| main.rs:455:9:455:14 | unused | Variable is not used. |
Original file line number Diff line number Diff line change @@ -439,8 +439,8 @@ fn folds_and_closures() {
439
439
trait Incrementable {
440
440
fn increment (
441
441
& mut self ,
442
- times : i32 , // SPURIOUS: unused variable
443
- unused : i32 // SPURIOUS: unused variable
442
+ times : i32 ,
443
+ unused : & mut i32
444
444
) ;
445
445
}
446
446
Original file line number Diff line number Diff line change 1
1
// --- generics ---
2
2
3
3
trait MySettable < T > {
4
- fn set ( & mut self , val : T ) ; // SPURIOUS: unused value
4
+ fn set ( & mut self , val : T ) ;
5
5
}
6
6
7
7
trait MyGettable < T > {
8
- fn get ( & self , val : T ) -> & T ; // SPURIOUS: unused value
8
+ fn get ( & self , val : T ) -> & T ;
9
9
}
10
10
11
11
struct MyContainer < T > {
You can’t perform that action at this time.
0 commit comments