derive(PartialEq) should not prevent "field is never read" warnings #134588
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-lints
Area: Lints (warnings about flaws in source code) such as unused_mut.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
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_use
for 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
The text was updated successfully, but these errors were encountered: