Closed m-rph closed 11 hours ago
PS - The original idea was for removing the Some
instead of changig filter_map
-> map
if it's Option<Option<T>>
(including references), but this is a good addition too :3
Is that machine applicable? I was thinking that removing Some
for Option<Option<_>>
means that it can't be followed by a map
with closure Option<_> -> T
, so we can't replace it.
I think it's the same rationale as to why iter_filter_is_some
is not machine applicable.
I don't think this is a clippy bug, but more like an enhancement?
It isn't machine applicable, yes
@rustbot claim
Assigning this to me as I am working on the sibling issue.
This should be under unnecessary_filter_map
, and should not be treated as a special case of filter_map_identity
.
This should be straightforward; Introduce a check in unnecessary_filter_map
to see whether the closure is |x| Some(x)
or simply a path to Some
.
@rustbot claim
@omer-shtivi are you planning on opening PR for this issue? I'm willing to take over this issue if you don't have time to do this/changed you mind
Hi @belyakov-am I'm still planning to do it, but it will just take me some time as I'm learning how to contribute to clippy
@m-rph @Centri3 hello there, could you assign this issue to me? I will rework the PR that was started by @omer-shtivi Looks like it ain't much left ~ETA: a few days
You may use @rustbot claim
@rustbot claim
Summary
When we encounter a
filter_map
on what is effectively an identity function followed bySome
, we shouldn't recommendmap(identity)
, but we should instead recommend completely removingfilter_map
.Many thanks to @Centri3 for finding this and #12501 .
Reproducer
I tried this code:
What I saw:
What I expected to see:
This is a follow up from #12501's discussion.
Version
Additional Labels
No response