False positive for clone_on_copy
when the clone is immediately borrowed
#1472
Labels
C-bug
Category: Clippy is not doing the correct thing
E-needs-mcve
Call for participation: This issue needs a Minimal Complete and Verifiable Example
I-false-positive
Issue: The lint was triggered on code it shouldn't have
T-middle
Type: Probably requires verifiying types
Consider
This triggers
clone_on_copy
, suggesting removing theclone
call. Taking the suggestion is illegal becauser
is not mutable. If it were mutable, taking the suggestion would change the behavior of the program.So it seems like we don't want to lint when the clone is immediately borrowed mutably.
You can also observe a difference (using
ref_eq
for example) when the clone is borrowed immutably, so perhaps it's better to lint only if the clone is immediately moved from?The text was updated successfully, but these errors were encountered: