option_if_let_else suggests invalid code when using mut references in the else clause #8141
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
There is a conditional branching code that uses
if let else
for the return value ofHashMap::get_mut()
.Even though the else clause of this code uses a mutable reference of the HashMap,
option_if_let_else
suggests to usemap_or_else()
, but the suggested code causes an error in the borrow checker.Lint Name
option_if_let_else
Reproducer
I tried this code:
I saw this happen:
The suggested code is not compilable:
Version
Additional Labels
No response
The text was updated successfully, but these errors were encountered: