mirror of
https://github.com/github/codeql.git
synced 2026-04-19 22:14:01 +02:00
Rust: Don't consider parameters in trait method definitions without bodies as variables
This commit is contained in:
@@ -84,7 +84,10 @@ module Impl {
|
||||
// an enum constant (e.g. `None`). This excludes static and constant variables (UPPERCASE),
|
||||
// which we don't appear to recognize yet anyway. This also assumes programmers follow the
|
||||
// naming guidelines, which they generally do, but they're not enforced.
|
||||
not name.charAt(0).isUppercase()
|
||||
not name.charAt(0).isUppercase() and
|
||||
// exclude parameters from functions without a bodies as these are trait method declarations
|
||||
// without implementations
|
||||
not exists(Function f | not f.hasBody() and f.getParamList().getAParam().getPat() = p)
|
||||
}
|
||||
|
||||
/** A variable. */
|
||||
|
||||
@@ -19,8 +19,6 @@
|
||||
| main.rs:370:9:370:9 | x | Variable is assigned a value that is never used. |
|
||||
| main.rs:378:17:378:17 | x | Variable is assigned a value that is never used. |
|
||||
| main.rs:432:9:432:10 | i6 | Variable is assigned a value that is never used. |
|
||||
| more.rs:4:23:4:25 | val | Variable is assigned a value that is never used. |
|
||||
| more.rs:8:19:8:21 | val | Variable is assigned a value that is never used. |
|
||||
| more.rs:24:9:24:11 | val | Variable is assigned a value that is never used. |
|
||||
| more.rs:46:9:46:14 | a_ptr4 | Variable is assigned a value that is never used. |
|
||||
| more.rs:61:9:61:13 | d_ptr | Variable is assigned a value that is never used. |
|
||||
|
||||
@@ -18,6 +18,4 @@
|
||||
| main.rs:379:21:379:21 | y | Variable is not used. |
|
||||
| main.rs:427:27:427:29 | val | Variable is not used. |
|
||||
| main.rs:430:22:430:24 | acc | Variable is not used. |
|
||||
| main.rs:442:9:442:13 | times | Variable is not used. |
|
||||
| main.rs:443:9:443:14 | unused | Variable is not used. |
|
||||
| main.rs:455:9:455:14 | unused | Variable is not used. |
|
||||
|
||||
@@ -439,8 +439,8 @@ fn folds_and_closures() {
|
||||
trait Incrementable {
|
||||
fn increment(
|
||||
&mut self,
|
||||
times: i32, // SPURIOUS: unused variable
|
||||
unused: i32 // SPURIOUS: unused variable
|
||||
times: i32,
|
||||
unused: &mut i32
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
// --- generics ---
|
||||
|
||||
trait MySettable<T> {
|
||||
fn set(&mut self, val: T); // SPURIOUS: unused value
|
||||
fn set(&mut self, val: T);
|
||||
}
|
||||
|
||||
trait MyGettable<T> {
|
||||
fn get(&self, val: T) -> &T; // SPURIOUS: unused value
|
||||
fn get(&self, val: T) -> &T;
|
||||
}
|
||||
|
||||
struct MyContainer<T> {
|
||||
|
||||
Reference in New Issue
Block a user