1
Fork 0

Respect -Z proc-macro-backtrace flag for panics inside libproc_macro

Fixes #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.
This commit is contained in:
Aaron Hill 2020-09-03 12:11:18 -04:00
parent 08deb863bd
commit 53cce257ae
No known key found for this signature in database
GPG key ID: B4087E510E98B164
4 changed files with 42 additions and 3 deletions

View file

@ -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();
@ -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)