rust-cli / human-panic

Panic messages for humans.
https://docs.rs/human-panic
Apache License 2.0
1.66k stars 65 forks source link

🙋 Including rustc version in report #31

Open phansch opened 6 years ago

phansch commented 6 years ago

Expected Behavior

I was investigating human-panic for possible usage in Clippy because we usually get a lot of failures due to being on nightly and depending on a lot of internal APIs.

Is there a possibility to include the current rustc version in the report? Ideally, that would include everything that's shown in rustc -vV.

Current Behavior

It's currently not included.

Possible Solution

I think executing rustc -vV, capturing the output and adding it to the report file should work, but not sure. I'd be happy to work on this if you have nothing against including that in the report.

spacekookie commented 6 years ago

I'm not sure it's possible to get the version of the compiler a Rust binary was built with after compilation. At most we could try to include that statically in the binary.

Running rustc -vV in the panic handler isn't a super great idea in my opinion because it assumes that the user of a tool even has Rust installed and it also only really gives useful diagnostics if they compiled the tool themselves instead of pulling it from a binary package (or similar).

killercup commented 6 years ago

You might want to take a look at what build info the sentry crate gathers: https://github.com/getsentry/sentry-rust/blob/8dbda94b81b6efd92dfd9cfffb25414cffdaee17/build.rs

yoshuawuyts commented 6 years ago

Oh, interesting - looks like we could add a build script to this crate, and use https://crates.io/crates/rustc_version to include the version! Nice one @killercup.

phansch commented 6 years ago

I'm working on integrating a similar build script into clippy right now, once that's done I'm happy to attempt the same here :+1:

spacekookie commented 6 years ago

ping @phansch did you ever finish the build script so we can steal it? :slightly_smiling_face:

phansch commented 6 years ago

Oh, I didn't end up doing it in the end and Clippy is available on stable now. I think using the build.rs from sentry should work out of the box: https://github.com/getsentry/sentry-rust/blob/master/build.rs

It generates a constants.gen.rs with RUSTC_VERSION, RUSTC_CHANNEL, PLATFORM and ARCH constants. You should then be able to use i.e. constants::RUSTC_VERSION when you generate the report.