Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions library/proc_macro/src/bridge/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ impl Bridge<'_> {
}

fn enter<R>(self, f: impl FnOnce() -> R) -> R {
let force_show_panics = self.force_show_panics;
// Hide the default panic output within `proc_macro` expansions.
// NB. the server can't do this because it may use a different libstd.
static HIDE_PANICS_DURING_EXPANSION: Once = Once::new();
Expand All @@ -313,9 +314,7 @@ impl Bridge<'_> {
panic::set_hook(Box::new(move |info| {
let show = BridgeState::with(|state| match state {
BridgeState::NotConnected => true,
// Something weird is going on, so don't suppress any backtraces
BridgeState::InUse => true,
BridgeState::Connected(bridge) => bridge.force_show_panics,
BridgeState::Connected(_) | BridgeState::InUse => force_show_panics,
});
if show {
prev(info)
Expand Down
13 changes: 13 additions & 0 deletions src/test/ui-fulldeps/auxiliary/proc-macro-panic.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// force-host
// no-prefer-dynamic

#![crate_type = "proc-macro"]

extern crate proc_macro;
use proc_macro::{TokenStream, Ident, Span};

#[proc_macro]
pub fn panic_in_libproc_macro(_: TokenStream) -> TokenStream {
Ident::new("", Span::call_site());
TokenStream::new()
}
17 changes: 17 additions & 0 deletions src/test/ui-fulldeps/issue-76270-panic-in-libproc-macro.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// aux-build:proc-macro-panic.rs
// edition:2018
// ignore-stage1
// only-linux
//
// FIXME: This should be a normal (stage1, all platforms) test in
// src/test/ui/proc-macro once issue #59998 is fixed.

// Regression test for issue #76270
// Tests that we don't print an ICE message when a panic
// occurs in libproc-macro (when `-Z proc-macro-backtrace` is not specified)

extern crate proc_macro_panic;

proc_macro_panic::panic_in_libproc_macro!(); //~ ERROR proc macro panicked

fn main() {}
10 changes: 10 additions & 0 deletions src/test/ui-fulldeps/issue-76270-panic-in-libproc-macro.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
error: proc macro panicked
--> $DIR/issue-76270-panic-in-libproc-macro.rs:15:1
|
LL | proc_macro_panic::panic_in_libproc_macro!();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: message: `""` is not a valid identifier

error: aborting due to previous error