Open
Description
openedon Apr 3, 2024
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment