-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed as duplicate of#88900
Closed as duplicate of#88900
Copy link
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.L-dead_codeLint: dead_codeLint: dead_codeS-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueStatus: A Minimal Complete and Verifiable Example has been found for this issueT-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
I tried this code:
#[derive(Debug)]
enum MyError {
IOErr(std::io::Error),
}
fn main() -> Result<(), MyError> {
let io_err = std::io::Error::new(std::io::ErrorKind::Other, "Some IO Error");
Err(MyError::IOErr(io_err))
}
I expect this to behave like so:
$ rustc ./main.rs
$ ./main
Error: IOErr(Custom { kind: Other, error: "Some IO Error" })
What I get is:
$ rustc ./main.rs
warning: field `0` is never read
--> ./main.rs:3:11
|
3 | IOErr(std::io::Error),
| ----- ^^^^^^^^^^^^^^
| |
| field in this variant
|
= note: `#[warn(dead_code)]` on by default
help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
|
3 | IOErr(()),
| ~~
warning: 1 warning emitted
$ ./main
Error: IOErr(Custom { kind: Other, error: "Some IO Error" })
Meta
rustc --version --verbose
:
rustc 1.77.1 (7cf61ebde 2024-03-27)
binary: rustc
commit-hash: 7cf61ebde7b22796c69757901dd346d0fe70bd97
commit-date: 2024-03-27
host: x86_64-apple-darwin
release: 1.77.1
LLVM version: 17.0.6
Backtrace
<backtrace>
Metadata
Metadata
Assignees
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.L-dead_codeLint: dead_codeLint: dead_codeS-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueStatus: A Minimal Complete and Verifiable Example has been found for this issueT-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.