-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
derive(PartialEq) should not prevent "field is never read" warnings #134588
Copy link
Copy link
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Code
Current output
Desired output
A warning for both MyStruct and MyStruct2.
Rationale and extra context
This was originally discussed on #84647 and #85200, although the conclusion there was to only exclude Debug and Clone.
However, it's really common to derive PartialEq on a type, especially when writing tests.
This means that adding tests can subtly stop this warning from catching issues. As far as I can see, there isn't a way to opt-in to stricter behaviour with either rustc or clippy here. There's no equivalent of
must_usefor struct fields, for example.This issue was the root of a nasty bug for me. Would you be open to making this diagnostic fire for more automatically derived traits?
Other cases
Rust Version
Anything else?
No response