"field is never read" warning despite Debug
being used explicitly in the code
#123562
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-lints
Area: Lints (warnings about flaws in source code) such as unused_mut.
C-bug
Category: This is a bug.
D-incorrect
Diagnostics: A diagnostic that is giving misleading or incorrect information.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Let's start from the case where
impl Display
is commented out.clippy
gives a dead code warning about the unusedString
field inError
(see the discussion in #88900).The suggested workaround is an explicit
Display
impl. But if I add that, using theDebug
internally to generate the displayed string, the warning is still there:In order to get rid of the warning, I must explicitly use the
.0
field in theDisplay
impl. While it is alright for this simple case, for error types which are enums with a lot of fields, this becomes very tiresome. Is it the intended behavior?Meta
rustc 1.77.1 (7cf61eb 2024-03-27)
binary: rustc
commit-hash: 7cf61eb
commit-date: 2024-03-27
host: aarch64-apple-darwin
release: 1.77.1
LLVM version: 17.0.6
(seems to have been introduced in 1.77.0)
The text was updated successfully, but these errors were encountered: