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 {
8484 // an enum constant (e.g. `None`). This excludes static and constant variables (UPPERCASE),
8585 // which we don't appear to recognize yet anyway. This also assumes programmers follow the
8686 // 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 )
8891 }
8992
9093 /** A variable. */
Original file line number Diff line number Diff line change 1919| main.rs:370:9:370:9 | x | Variable is assigned a value that is never used. |
2020| main.rs:378:17:378:17 | x | Variable is assigned a value that is never used. |
2121| 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. |
2422| more.rs:24:9:24:11 | val | Variable is assigned a value that is never used. |
2523| more.rs:46:9:46:14 | a_ptr4 | Variable is assigned a value that is never used. |
2624| 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 1818| main.rs:379:21:379:21 | y | Variable is not used. |
1919| main.rs:427:27:427:29 | val | Variable is not used. |
2020| 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. |
2321| 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() {
439439trait Incrementable {
440440 fn increment (
441441 & mut self ,
442- times : i32 , // SPURIOUS: unused variable
443- unused : i32 // SPURIOUS: unused variable
442+ times : i32 ,
443+ unused : & mut i32
444444 ) ;
445445}
446446
Original file line number Diff line number Diff line change 11// --- generics ---
22
33trait MySettable < T > {
4- fn set ( & mut self , val : T ) ; // SPURIOUS: unused value
4+ fn set ( & mut self , val : T ) ;
55}
66
77trait MyGettable < T > {
8- fn get ( & self , val : T ) -> & T ; // SPURIOUS: unused value
8+ fn get ( & self , val : T ) -> & T ;
99}
1010
1111struct MyContainer < T > {
You can’t perform that action at this time.
0 commit comments