Skip to content

Commit

Permalink
Call the panic hook for non-unwind panics in proc-macros
Browse files Browse the repository at this point in the history
  • Loading branch information
saethlin committed Apr 11, 2024
1 parent aa6a697 commit 036e538
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion library/proc_macro/src/bridge/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,11 @@ fn maybe_install_panic_hook(force_show_panics: bool) {
HIDE_PANICS_DURING_EXPANSION.call_once(|| {
let prev = panic::take_hook();
panic::set_hook(Box::new(move |info| {
if force_show_panics || !is_available() {
// We normally report panics by catching unwinds and passing the payload from the
// unwind back to the compiler, but if the panic doesn't unwind we'll abort before
// the compiler has a chance to print an error. So we special-case PanicInfo where
// can_unwind is false.
if force_show_panics || !is_available() || !info.can_unwind() {
prev(info)
}
}));
Expand Down

0 comments on commit 036e538

Please sign in to comment.