rust-lang / rustc_codegen_cranelift

Cranelift based backend for rustc
Apache License 2.0
1.6k stars 101 forks source link

Unhelful error message when proc macro fails #1174

Open vi opened 3 years ago

vi commented 3 years ago

With cargo build --release I get:

error: proc-macro derive panicked
 --> websocat-syncnodes/src/net.rs:2:22
  |
2 | #[derive(Debug,Clone,websocat_derive::WebsocatNode)]
  |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = help: message: Set exactly one of official_name or no_class

But when using cg_clif's cargo wrapper, I get:

error: could not compile `websocat-syncnodes`

Caused by:
  process didn't exit successfully: `/home/vi/src/rustc_codegen_cranelift/build/bin/cg_clif --crate-name  ...
vi commented 3 years ago

It also shows error: internal compiler error: unexpected panic with an invitation to file a bug when a proc macro panics and the error message is actually visible.

     Running `/home/vi/src/rustc_codegen_cranelift/build/bin/cg_clif --crate-name websocat_basic --edition=2018 websocat-basic/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 --cfg 'feature="default"' --cfg 'feature="fs"' --cfg 'feature="io-std"' --cfg 'feature="net"' --cfg 'feature="process"' --cfg 'feature="race"' -C metadata=89e2211acced995a -C extra-filename=-89e2211acced995a --out-dir /mnt/bkel/vi/code/websocat3/target/debug/deps -C incremental=/mnt/bkel/vi/code/websocat3/target/debug/incremental -L dependency=/mnt/bkel/vi/code/websocat3/target/debug/deps --extern tokio=/mnt/bkel/vi/code/websocat3/target/debug/deps/libtokio-34da4925dae4dbdd.rmeta --extern tracing=/mnt/bkel/vi/code/websocat3/target/debug/deps/libtracing-fbdb7778389c6803.rmeta --extern websocat_api=/mnt/bkel/vi/code/websocat3/target/debug/deps/libwebsocat_api-804d017780e84ed0.rmeta --extern websocat_derive=/mnt/bkel/vi/code/websocat3/target/debug/deps/libwebsocat_derive-df994aa862cead6a.so`
thread 'rustc' panicked at 'called `Result::unwrap()` on an `Err` value: Error { kind: MissingField("official_name"), locations: [], span: None }', websocat-derive/src/lib.rs:168:47
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.54.0-nightly (3e99439f4 2021-05-17) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type lib

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
error: could not compile `websocat-basic`
bjorn3 commented 3 years ago

cg_clif doesn't yet support unwinding on panics and as such the whole rustc process aborts on a panic.

vi commented 3 years ago

Maybe some short-term changes can be done easily?

  1. Remove or change "we would appreciate a bug report:", so that would warn about using cg_clif and/or point to this issue tracker, not rust-lang/rust's. Maybe this can even be done in Cargo wrapper shell script, not from within cg_clif.
  2. Make it output longer error message (like in the second comment), not just error: could not compile crate-name (like in the first one)
bjorn3 commented 3 years ago

https://github.com/rust-lang/rust/pull/85640 will change the bug report url to cg_clif's issue tracker. As for the second point I am not sure why it doesn't show anything other than that compilation failed.