Closed taiki-e closed 2 years ago
Do you have an example of how this looks with a real error, before and after?
Here is the current output and the output after this PR has been applied:
ErrorKind::Io
:
Before:
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { kind: Io(Os { code: 2, kind: NotFound, message: "No such file or directory" }) }', autocfg/src/lib.rs:137:28
After:
thread 'main' panicked at 'No such file or directory (os error 2)', autocfg/src/lib.rs:146:47
ErrorKind::Num
:
Before:
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { kind: Num(ParseIntError { kind: InvalidDigit }) }', autocfg/src/lib.rs:137:28
After:
thread 'main' panicked at 'invalid digit found in string', autocfg/src/lib.rs:146:47
ErrorKind::Utf8
:
Before:
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { kind: Utf8(Utf8Error { valid_up_to: 1, error_len: Some(1) }) }', autocfg/src/lib.rs:137:28
After:
thread 'main' panicked at 'invalid utf-8 sequence of 1 bytes from index 1', autocfg/src/lib.rs:146:47
ErrorKind::Other
:
Before:
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { kind: Other("could not find rustc release") }', autocfg/src/lib.rs:137:28
After:
thread 'main' panicked at 'could not find rustc release', autocfg/src/lib.rs:146:47
If the problem is just the verbosity of
derive(Debug)
, we could implement that manually to look more likeDisplay
.
I think verbosity is the main problem, but I think the output of .unwrap
(i.e., "called Result::unwrap()
on an Err
value:") is also verbose. Here is output if use fmt::Display::fmt
in Debug
impl:
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: No such file or directory (os error 2)', autocfg/src/lib.rs:137:28
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: invalid digit found in string', autocfg/src/lib.rs:137:28
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: invalid utf-8 sequence of 1 bytes from index 1', autocfg/src/lib.rs:137:28
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: could not find rustc release', autocfg/src/lib.rs:137:28
Closing -- I no longer need this as I replaced all use of autocfg::new
with autocfg::AutoCfg::new
like https://github.com/crossbeam-rs/crossbeam/pull/604.
Do you have an example of how this looks with a real error, before and after?
If the problem is just the verbosity of
derive(Debug)
, we could implement that manually to look more likeDisplay
.