Rust: Move trait tests for unused entities into main.rs

This commit is contained in:
Simon Friis Vindum
2024-10-25 15:15:49 +02:00
parent 45e9c2ff4d
commit a5ce3c1570
4 changed files with 41 additions and 43 deletions

View File

@@ -19,15 +19,12 @@
| 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:8:9:8:13 | times | Variable is assigned a value that is never used. |
| more.rs:9:9:9:14 | unused | Variable is assigned a value that is never used. |
| more.rs:21:9:21:14 | unused | Variable is assigned a value that is never used. |
| more.rs:38:23:38:25 | val | Variable is assigned a value that is never used. |
| more.rs:42:19:42:21 | val | Variable is assigned a value that is never used. |
| more.rs:58:9:58:11 | val | Variable is assigned a value that is never used. |
| more.rs:80:9:80:14 | a_ptr4 | Variable is assigned a value that is never used. |
| more.rs:95:9:95:13 | d_ptr | Variable is assigned a value that is never used. |
| more.rs:101:9:101:17 | f_ptr | 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. |
| more.rs:67:9:67:17 | f_ptr | Variable is assigned a value that is never used. |
| unreachable.rs:166:6:166:6 | x | Variable is assigned a value that is never used. |
| unreachable.rs:190:14:190:14 | a | Variable is assigned a value that is never used. |
| unreachable.rs:199:9:199:9 | a | Variable is assigned a value that is never used. |

View File

@@ -18,3 +18,6 @@
| 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. |

View File

@@ -434,6 +434,38 @@ fn folds_and_closures() {
_ = a6.fold(0, | acc, val | acc + val + i6);
}
// --- traits ---
trait Incrementable {
fn increment(
&mut self,
times: i32, // SPURIOUS: unused variable
unused: i32 // SPURIOUS: unused variable
);
}
struct MyValue {
value: i32,
}
impl Incrementable for MyValue {
fn increment(
&mut self,
times: i32,
unused: i32 // BAD: unused variable
) {
self.value += times;
}
}
fn traits() {
let mut i = MyValue { value: 0 };
let a = 1;
let b = 2;
i.increment(a, b);
}
// --- main ---
fn main() {

View File

@@ -1,37 +1,3 @@
// --- traits ---
trait Incrementable {
fn increment(
&mut self,
times: i32, // SPURIOUS: unused value
unused: i32 // SPURIOUS: unused value
);
}
struct MyValue {
value: i32,
}
impl Incrementable for MyValue {
fn increment(
&mut self,
times: i32,
unused: i32 // BAD: unused variable [NOT DETECTED] SPURIOUS: unused value
) {
self.value += times;
}
}
fn traits() {
let mut i = MyValue { value: 0 };
let a = 1;
let b = 2;
i.increment(a, b);
}
// --- generics ---
trait MySettable<T> {