Open
Description
Summary
Clippy forgot about the {}
for the suggestions.
Reproducer
Playground: https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=3dedb348e9d9b077d3bcaa43ff1bc346
const LANGUAGE_ROWS: [u8; 0] = [];
#[warn(clippy::needless_for_each)]
fn main() {
let mut v = vec![];
LANGUAGE_ROWS.iter().for_each(|x| _ = v.push(x));
}
Checking playground v0.0.1 (/playground)
warning: needless use of `for_each`
--> src/main.rs:6:5
|
6 | LANGUAGE_ROWS.iter().for_each(|x| _ = v.push(x));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x in LANGUAGE_ROWS.iter() _ = v.push(x)`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_for_each
note: the lint level is defined here
--> src/main.rs:3:8
|
3 | #[warn(clippy::needless_for_each)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
warning: this let-binding has unit value
--> src/main.rs:6:39
|
6 | LANGUAGE_ROWS.iter().for_each(|x| _ = v.push(x));
| ^^^^^^^^^^^^^ help: omit the `let` binding: `v.push(x);`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#let_unit_value
= note: `#[warn(clippy::let_unit_value)]` on by default
warning: `playground` (bin "playground") generated 2 warnings (run `cargo clippy --fix --bin "playground"` to apply 2 suggestions)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.75s
Version
rustc 1.86.0 (05f9846f8 2025-03-31)
binary: rustc
commit-hash: 05f9846f893b09a1be1fc8560e33fc3c815cfecb
commit-date: 2025-03-31
host: x86_64-unknown-linux-gnu
release: 1.86.0
LLVM version: 19.1.7
Additional Labels
No response