-
Notifications
You must be signed in to change notification settings - Fork 2k
Incorrect clippy::derivable_impls in the presence of conditional compilation #13160
Copy link
Copy link
Open
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't haveI-suggestion-causes-bugIssue: The suggestion compiles but changes the code to behave in an unintended wayIssue: The suggestion compiles but changes the code to behave in an unintended wayS-blockedStatus: marked as blocked ❌ on something else such as an RFC or other implementation workStatus: marked as blocked ❌ on something else such as an RFC or other implementation work
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't haveI-suggestion-causes-bugIssue: The suggestion compiles but changes the code to behave in an unintended wayIssue: The suggestion compiles but changes the code to behave in an unintended wayS-blockedStatus: marked as blocked ❌ on something else such as an RFC or other implementation workStatus: marked as blocked ❌ on something else such as an RFC or other implementation work
Type
Fields
Give feedbackNo fields configured for issues without a type.
Summary
Clippy will happily change the meaning of code using conditional compilation inside a custom
Defaultwhen using--fix. The code compiles but is now incorrect.Lint Name
clippy::derivable_impls
Reproducer
I tried this code:
I saw this happen:
With
--fixit 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
--fixis:I expected to see this happen:
Either Clippy should use
cfg_attrhere 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