-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
rustc complains about unused code if item is used in #[automatically_derived] context #126031
Copy link
Copy link
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.Category: This is a bug.P-lowLow priorityLow priorityT-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.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.Category: This is a bug.P-lowLow priorityLow priorityT-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.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Code
I tried this code:
I expected to see this happen: The code compiles without any warnings since, the
Identitystruct is clearly used.Instead, this happened: The compiler emits a
dead_codelint, telling me that the struct is never constructedExample where this can occur: when using the
derive_morecrate to derive a specializedDebugimplementation, and the usage ofderive_more::Debugutilizes a formatter struct to avoid allocating into an intermediate heap allocated bufferReal-world example
Version it worked on
It most recently worked on: Rust 1.77.2
Version with regression
rustc --version --verbose:@rustbot modify labels: +regression-from-stable-to-stable -regression-untriaged