Skip to content

Commit e1fa44d

Browse files
committed
Auto merge of rust-lang#76292 - Aaron1011:fix/proc-macro-panic-hide, r=petrochenkov
Respect `-Z proc-macro-backtrace` flag for panics inside libproc_macro Fixes rust-lang#76270 Previously, any panic occuring during a call to a libproc_macro method (e.g. calling `Ident::new` with an invalid identifier) would always cause an ICE message to be printed.
2 parents 847c850 + 9a05bd6 commit e1fa44d

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

proc_macro/src/bridge/client.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ impl Bridge<'_> {
305305
}
306306

307307
fn enter<R>(self, f: impl FnOnce() -> R) -> R {
308+
let force_show_panics = self.force_show_panics;
308309
// Hide the default panic output within `proc_macro` expansions.
309310
// NB. the server can't do this because it may use a different libstd.
310311
static HIDE_PANICS_DURING_EXPANSION: Once = Once::new();
@@ -313,9 +314,7 @@ impl Bridge<'_> {
313314
panic::set_hook(Box::new(move |info| {
314315
let show = BridgeState::with(|state| match state {
315316
BridgeState::NotConnected => true,
316-
// Something weird is going on, so don't suppress any backtraces
317-
BridgeState::InUse => true,
318-
BridgeState::Connected(bridge) => bridge.force_show_panics,
317+
BridgeState::Connected(_) | BridgeState::InUse => force_show_panics,
319318
});
320319
if show {
321320
prev(info)

0 commit comments

Comments
 (0)