Closed
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.