-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
It would be nice if Clippy could also warn me about using then_some in return of a find_map closure, like in this example:
std::iter::once(1).find_map(|n| (n > 1).then_some(n));
Lint Name
unnecessary_find_map
Reproducer
I tried this code:
// warns
std::iter::once(1).find_map(|n| if n > 1 { Some(n) } else { None });
// does not
std::iter::once(1).find_map(|n| (n > 1).then_some(n));
// better solution
std::iter::once(1).find(|n| *n > 1);I expected to see this happen:
The unnecessary_find_map lint should flag the second example as well
Instead, this happened:
No warning is emitted
Version
No response
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