-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-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.
Description
Given the following code: [playground]
#[derive(Default)]
struct T {}
struct U {}
The current output is:
warning: struct `U` is never constructed
--> src/lib.rs:4:8
|
4 | struct U {}
| ^
|
= note: `#[warn(dead_code)]` on by default
Ideally the output should look like:
warning: struct `T` is never constructed
--> src/lib.rs:2:8
|
2 | struct T {}
| ^
|
= note: `#[warn(dead_code)]` on by default
warning: struct `U` is never constructed
--> src/lib.rs:4:8
|
4 | struct U {}
| ^
After the derive, the code looks roughly like
struct T {}
#[automatically_derived]
impl Default for T {
#[inline]
fn default() -> T { T {} }
}
struct U {}
As the default implementation is both 1) itself unused and 2) #[automatically_derived]
, ideally it should not count as a use for suppressing the dead_code
lint on T
.
The derived implementations for Clone
, Debug
, PartialEq
, and Hash
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.
TaKO8Ki, pro465, crumblingstatue and veber-alex
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-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.