-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
derive(Default) suppresses warn(dead_code) #98871
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Comments
CAD97
added
A-diagnostics
Area: Messages for errors, warnings, and lints
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
labels
Jul 4, 2022
Probably a duplicate of #47851 |
Definitely related but maybe not a duplicate; #47851 is about explicit impls whereas this is a subset for just |
I thought the dead code lint (or other lints?) actually mentioned they didn't do this explicitly. Like, "this lint ignores automatic derives" or something. |
Ah, unused field lint does:
|
bors
added a commit
to rust-lang-ci/rust
that referenced
this issue
Jun 25, 2024
…ichaelwoerister Detect unused structs which derived Default <!-- If this PR is related to an unstable feature or an otherwise tracked effort, please link to the relevant tracking issue here. If you don't know of a related tracking issue or there are none, feel free to ignore this. This PR will get automatically assigned to a reviewer. In case you would like a specific user to review your work, you can assign it to them by using r? <reviewer name> --> Fixes rust-lang#98871
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this issue
Jun 25, 2024
Rollup merge of rust-lang#126302 - mu001999-contrib:ignore/default, r=michaelwoerister Detect unused structs which derived Default <!-- If this PR is related to an unstable feature or an otherwise tracked effort, please link to the relevant tracking issue here. If you don't know of a related tracking issue or there are none, feel free to ignore this. This PR will get automatically assigned to a reviewer. In case you would like a specific user to review your work, you can assign it to them by using r? <reviewer name> --> Fixes rust-lang#98871
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Given the following code: [playground]
The current output is:
Ideally the output should look like:
After the derive, the code looks roughly like
As the default implementation is both 1) itself unused and 2)
#[automatically_derived]
, ideally it should not count as a use for suppressing thedead_code
lint onT
.The derived implementations for
Clone
,Debug
,PartialEq
, andHash
also show this behavior.I seem to recall a previous change to
#[automatically_derived]
to change the interaction between the unused code lint and derived implementations, but could not find it offhand.The text was updated successfully, but these errors were encountered: