cuviper / autocfg

Automatic cfg for Rust compiler features
Apache License 2.0
95 stars 24 forks source link

Improve panic message of autocfg::new #29

Closed taiki-e closed 2 years ago

cuviper commented 3 years ago

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 like Display.

taiki-e commented 3 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:


If the problem is just the verbosity of derive(Debug), we could implement that manually to look more like Display.

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
taiki-e commented 2 years ago

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.