Wrong lint in case of to_*_mut
method
#6758
Labels
C-bug
Category: Clippy is not doing the correct thing
good-first-issue
These issues are a good way to get started with Clippy
I-false-positive
Issue: The lint was triggered on code it shouldn't have
Lint name:
wrong_self_convention
I tried this code:
I expected to see this happen: in order to get an optional variant of the enum, the naming convention
to_*
should be used, because thematch
statement cannot be considered free (thereforeas_*
is not ok). Moreover, the nameto_mut
(à laCow::to_mut
) cannot be used in this case, because there are two non-empty variants. Therefore usingto_many_mut
for the name of the method seems the right choice.Instead, this happened: clippy says that
to_*
should follow the convention of takingself
by reference.My rationale is that, when a method starts with
to_
, it should expect a&mut self
parameter if ends with_mut
, otherwise&self
.Meta
cargo clippy -V
: clippy 0.0.212 (cb75ad5 2021-02-10)rustc -Vv
:The text was updated successfully, but these errors were encountered: