Summary
The lint is not triggered when iterating over a HashMap with iter{_mut} and destructuring the key as _, even though only the values are used.
Lint Name
for_kv_map
Reproducer
I tried this code:
pub fn m1(mut x: HashMap<usize, usize>) {
for (_, v) in x.iter_mut() {
black_box(v);
}
}
https://rust.godbolt.org/z/qshMWz8xr
I expected to see this happen:
warning: you seem to want to iterate on a map's values
--> <source>:6:19
|
13 | for (_, v) in x.iter_mut() {
| ^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.94.0/index.html#for_kv_map
= note: `#[warn(clippy::for_kv_map)]` on by default
help: use the corresponding method
|
13 - for (_, y) in x.iter_mut() {
13 + for v in x.values_mut() {
|
Instead, this happened:
No warning emitted.
Version
Summary
The lint is not triggered when iterating over a
HashMapwithiter{_mut}and destructuring the key as_, even though only the values are used.Lint Name
for_kv_mapReproducer
I tried this code:
https://rust.godbolt.org/z/qshMWz8xr
I expected to see this happen:
Instead, this happened:
No warning emitted.
Version