-
Notifications
You must be signed in to change notification settings - Fork 13k
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
field "never read" warning for field that is used by derive(Debug) #123068
Comments
Derived code is intentionally ignored for dead code analysis - if you try just use std::str;
#[derive(Debug)]
enum ProcessError {
Utf8(str::Utf8Error),
Other,
} You'll get a note explaining this. The note doesn't seem to be attached for |
Ah, so it's intentional. Interesting. I assume the solution is to mark it with |
@rustbot claim |
@rustbot release-assignment |
@rustbot claim |
Note that while getting a warning if |
As mentioned above, the fix for this issue is adding a note about how derived traits are intentionally ignored, not to stop ignoring them. |
…enum-with-debug, r=pnkfelix Show notice about "never used" of Debug for enum Close rust-lang#123068 If an ADT implements `Debug` trait and it is not used, the compiler says a note that indicates intentionally ignored during dead code analysis as [this note](https://github.com/rust-lang/rust/blob/2207179a591f5f252885a94ab014dafeb6e8e9e8/tests/ui/lint/dead-code/unused-variant.stderr#L9). However this node is not shown for variants that have fields in enum. This PR fixes to show the note.
…enum-with-debug, r=pnkfelix Show notice about "never used" of Debug for enum Close rust-lang#123068 If an ADT implements `Debug` trait and it is not used, the compiler says a note that indicates intentionally ignored during dead code analysis as [this note](https://github.com/rust-lang/rust/blob/2207179a591f5f252885a94ab014dafeb6e8e9e8/tests/ui/lint/dead-code/unused-variant.stderr#L9). However this node is not shown for variants that have fields in enum. This PR fixes to show the note.
Rollup merge of rust-lang#124460 - long-long-float:show-notice-about-enum-with-debug, r=pnkfelix Show notice about "never used" of Debug for enum Close rust-lang#123068 If an ADT implements `Debug` trait and it is not used, the compiler says a note that indicates intentionally ignored during dead code analysis as [this note](https://github.com/rust-lang/rust/blob/2207179a591f5f252885a94ab014dafeb6e8e9e8/tests/ui/lint/dead-code/unused-variant.stderr#L9). However this node is not shown for variants that have fields in enum. This PR fixes to show the note.
I tried this code:
I expected to see this happen: build cleanly
Instead, this happened:
Running the program shows the field is used:
Meta
Rust version 1.77.0 (tested in playground)
The text was updated successfully, but these errors were encountered: