-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-negativeIssue: The lint should have been triggered on code, but wasn'tIssue: The lint should have been triggered on code, but wasn't
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
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-negativeIssue: The lint should have been triggered on code, but wasn'tIssue: The lint should have been triggered on code, but wasn't