Suggested map_or_else when value partialy moved #13964
Labels
C-bug
Category: Clippy is not doing the correct thing
E-medium
Call for participation: Medium difficulty level problem and requires some initial experience.
I-false-positive
Issue: The lint was triggered on code it shouldn't have
I-suggestion-causes-error
Issue: The suggestions provided by this Lint cause an ICE/error when applied
Summary
The
clippy::map_or_else
lint suggests erroneous code when partially moving the value in one arm and using it in another.The ownership is dropped before the test for a
map_or_else
, but only after the test when doing a match.Lint Name
map_or_else
Reproducer
I tried this code
I saw this happen
If I follow the lint
I get a compilation error:
borrow of partially moved value: a
(this is normal asa
is moved when accessing the0
field).I expected
I expected the warning not to be triggered in this case
Version
Additional Labels
@rustbot label +I-suggestion-causes-error
@rustbot label +E-medium
The text was updated successfully, but these errors were encountered: