about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorAaron Hill <aa1ronham@gmail.com>2020-08-30 22:17:24 -0400
committerAaron Hill <aa1ronham@gmail.com>2020-08-30 22:17:24 -0400
commitd9208665b5eef883c025f44717f8c76afa871a94 (patch)
tree176013005f76e7122dcf00a1de9a9a0d20e9db47 /src/test
parent36b0d7e25769e88fec85e1d073196065a7f2d7c4 (diff)
downloadrust-d9208665b5eef883c025f44717f8c76afa871a94.tar.gz
rust-d9208665b5eef883c025f44717f8c76afa871a94.zip
Add `-Z proc-macro-backtrace` to allow showing proc-macro panics
Fixes #75050

Previously, we would unconditionally suppress the panic hook during
proc-macro execution. This commit adds a new flag
-Z proc-macro-backtrace, which allows running the panic hook for
easier debugging.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/proc-macro/load-panic-backtrace.rs21
-rw-r--r--src/test/ui/proc-macro/load-panic-backtrace.stderr11
2 files changed, 32 insertions, 0 deletions
diff --git a/src/test/ui/proc-macro/load-panic-backtrace.rs b/src/test/ui/proc-macro/load-panic-backtrace.rs
new file mode 100644
index 00000000000..90fe109abb8
--- /dev/null
+++ b/src/test/ui/proc-macro/load-panic-backtrace.rs
@@ -0,0 +1,21 @@
+// aux-build:test-macros.rs
+// compile-flags: -Z proc-macro-backtrace
+// rustc-env:RUST_BACKTRACE=0
+
+// FIXME https://github.com/rust-lang/rust/issues/59998
+// normalize-stderr-test "thread '.*' panicked " -> ""
+// normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> ""
+// normalize-stderr-test "\nerror: internal compiler error.*\n\n" -> ""
+// normalize-stderr-test "note:.*unexpectedly panicked.*\n\n" -> ""
+// normalize-stderr-test "note: we would appreciate a bug report.*\n\n" -> ""
+// normalize-stderr-test "note: compiler flags.*\n\n" -> ""
+// normalize-stderr-test "note: rustc.*running on.*\n\n" -> ""
+
+#[macro_use]
+extern crate test_macros;
+
+#[derive(Panic)]
+//~^ ERROR: proc-macro derive panicked
+struct Foo;
+
+fn main() {}
diff --git a/src/test/ui/proc-macro/load-panic-backtrace.stderr b/src/test/ui/proc-macro/load-panic-backtrace.stderr
new file mode 100644
index 00000000000..63378b5735a
--- /dev/null
+++ b/src/test/ui/proc-macro/load-panic-backtrace.stderr
@@ -0,0 +1,11 @@
+at 'panic-derive', $DIR/auxiliary/test-macros.rs:43:5
+error: proc-macro derive panicked
+  --> $DIR/load-panic-backtrace.rs:17:10
+   |
+LL | #[derive(Panic)]
+   |          ^^^^^
+   |
+   = help: message: panic-derive
+
+error: aborting due to previous error
+