clippy::map_entry false positive with let-else #12489
Labels
C-bug
Category: Clippy is not doing the correct thing
I-false-positive
Issue: The lint was triggered on code it shouldn't have
Summary
The
clippy::map_entry
seems to have a false-positive when usinglet-else
. I've looked for similar issues in the tracker but couldn't find any so opening this one - apologies if I missed one.The lint suggests to use
or_insert_with
which makes theelse
part return out of the closure instead of out of the function. Because they expect different return types (the closure expects aString
, the function expects anOption<&String>
in https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=8b9c4d6dad5586827f5906400a480391), it leads to a compilation error.Lint Name
clippy::map_entry
Reproducer
I tried this code (also available at https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=8b9c4d6dad5586827f5906400a480391):
I saw this happen:
Version
Additional Labels
No response
The text was updated successfully, but these errors were encountered: