Skip to content

Commit 4a8f091

Browse files
saethlincuviper
authored andcommitted
Call the panic hook for non-unwind panics in proc-macros
(cherry picked from commit d8dc28b)
1 parent 8fcffff commit 4a8f091

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

library/proc_macro/src/bridge/client.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,11 @@ fn maybe_install_panic_hook(force_show_panics: bool) {
286286
BridgeState::NotConnected => true,
287287
BridgeState::Connected(_) | BridgeState::InUse => force_show_panics,
288288
});
289-
if show {
289+
// We normally report panics by catching unwinds and passing the payload from the
290+
// unwind back to the compiler, but if the panic doesn't unwind we'll abort before
291+
// the compiler has a chance to print an error. So we special-case PanicInfo where
292+
// can_unwind is false.
293+
if show || !info.can_unwind() {
290294
prev(info)
291295
}
292296
}));

library/proc_macro/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#![feature(maybe_uninit_write_slice)]
3131
#![feature(negative_impls)]
3232
#![feature(new_uninit)]
33+
#![feature(panic_can_unwind)]
3334
#![feature(restricted_std)]
3435
#![feature(rustc_attrs)]
3536
#![feature(min_specialization)]

0 commit comments

Comments
 (0)