Incorrect clippy::derivable_impls in the presence of conditional compilation #13160
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
I-suggestion-causes-bug
Issue: The suggestion compiles but changes the code to behave in an unintended way
Summary
Clippy will happily change the meaning of code using conditional compilation inside a custom
Default
when using--fix
. The code compiles but is now incorrect.Lint Name
clippy::derivable_impls
Reproducer
I tried this code:
I saw this happen:
With
--fix
it creates the following code that is not equivalent (when no features are enabled, you will get different variants of this depending on what features are enabled)The reported clippy message without
--fix
is:I expected to see this happen:
Either Clippy should use
cfg_attr
here on default, or if that is too complicated it should detect that it breaks the code and refuse to auto-fix it.Version
Additional Labels
@rustbot label +I-suggestion-causes-bug
The text was updated successfully, but these errors were encountered: