Open
Description
Summary
If the identity function passed to flat_map_identity de- and re-builds the object (e.g. |[x, y]| [x, y]
), then the lint doesn't fire.
Lint Name
flat_map_identity
Reproducer
I tried this code:
fn main() {
let i = std::iter::empty::<[f32; 2]>();
for e in i.flat_map(|[x, y]| [x, y]) {
println!("{e:?}");
}
I expected to see this happen:
use of `flat_map` with an identity function
as happens with .flat_map(|e| e)
.
Instead, this happened:
[no error]
Version
rustc 1.90.0-nightly (71e4c005c 2025-07-01)
binary: rustc
commit-hash: 71e4c005caa812a16fcb08d0bf1e6f1eda7c8381
commit-date: 2025-07-01
host: x86_64-unknown-linux-gnu
release: 1.90.0-nightly
LLVM version: 20.1.7