Add test for an interesting edge case
This commit is contained in:
parent
cb3bb8a5b5
commit
fbb7fd59c3
@ -1,7 +1,7 @@
|
||||
#![allow(unused)]
|
||||
#![warn(clippy::collection_is_never_read)]
|
||||
|
||||
use std::collections::{HashSet, HashMap};
|
||||
use std::collections::{HashMap, HashSet};
|
||||
|
||||
fn main() {}
|
||||
|
||||
@ -126,3 +126,10 @@ fn insert_is_a_read() {
|
||||
println!("5 was inserted");
|
||||
}
|
||||
}
|
||||
|
||||
fn not_read_if_return_value_not_used() {
|
||||
// `is_empty` does not modify the set, so it's a query. But since the return value is not used, the
|
||||
// lint does not consider it a read here.
|
||||
let x = vec![1, 2, 3]; // WARNING
|
||||
x.is_empty();
|
||||
}
|
||||
|
@ -42,5 +42,11 @@ error: collection is never read
|
||||
LL | let mut x = HashSet::new(); // WARNING
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 7 previous errors
|
||||
error: collection is never read
|
||||
--> $DIR/collection_is_never_read.rs:133:5
|
||||
|
|
||||
LL | let x = vec![1, 2, 3]; // WARNING
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 8 previous errors
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user