aboutsummaryrefslogtreecommitdiff
path: root/crates/proc_macro_srv/src/proc_macro/bridge/client.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-12-27 13:30:06 +0000
committerGitHub <[email protected]>2020-12-27 13:30:06 +0000
commit0fd75c98ac81c9f6581712ec8802940e547315e3 (patch)
tree7d7dc80327900207912b1d4e952c012d4dd403b7 /crates/proc_macro_srv/src/proc_macro/bridge/client.rs
parent1d874a2a65278548a781c6cc518ae7dd7c741229 (diff)
parentda92f46cc8b5fc7e45cd35117ca4cb0cff80405e (diff)
Merge #7047
7047: Add force_show_panics flag for proc-macro bridge r=jonas-schievink a=edwin0cheng https://github.com/rust-lang/rust/pull/75082 and https://github.com/rust-lang/rust/pull/76292 added a new flag in `proc_macro::Bridge` such that the ABI was changed. These ABI changing are the reason of some weird panics which caused #6880 and maybe related to the panic mentioned in #6820. These changes are landed on rust stable 1.48 so I think it is okay to apply it now. fixes #6880 r @jonas-schievink Co-authored-by: Edwin Cheng <[email protected]>
Diffstat (limited to 'crates/proc_macro_srv/src/proc_macro/bridge/client.rs')
-rw-r--r--crates/proc_macro_srv/src/proc_macro/bridge/client.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/crates/proc_macro_srv/src/proc_macro/bridge/client.rs b/crates/proc_macro_srv/src/proc_macro/bridge/client.rs
index 55d6330cc..ca6749b9b 100644
--- a/crates/proc_macro_srv/src/proc_macro/bridge/client.rs
+++ b/crates/proc_macro_srv/src/proc_macro/bridge/client.rs
@@ -303,17 +303,21 @@ impl BridgeState<'_> {
303 303
304impl Bridge<'_> { 304impl Bridge<'_> {
305 fn enter<R>(self, f: impl FnOnce() -> R) -> R { 305 fn enter<R>(self, f: impl FnOnce() -> R) -> R {
306 let force_show_panics = self.force_show_panics;
307
306 // Hide the default panic output within `proc_macro` expansions. 308 // Hide the default panic output within `proc_macro` expansions.
307 // NB. the server can't do this because it may use a different libstd. 309 // NB. the server can't do this because it may use a different libstd.
308 static HIDE_PANICS_DURING_EXPANSION: Once = Once::new(); 310 static HIDE_PANICS_DURING_EXPANSION: Once = Once::new();
309 HIDE_PANICS_DURING_EXPANSION.call_once(|| { 311 HIDE_PANICS_DURING_EXPANSION.call_once(|| {
310 let prev = panic::take_hook(); 312 let prev = panic::take_hook();
311 panic::set_hook(Box::new(move |info| { 313 panic::set_hook(Box::new(move |info| {
312 let hide = BridgeState::with(|state| match state { 314 let show = BridgeState::with(|state| match state {
313 BridgeState::NotConnected => false, 315 BridgeState::NotConnected => true,
314 BridgeState::Connected(_) | BridgeState::InUse => true, 316 // Something weird is going on, so don't suppress any backtraces
317 BridgeState::InUse => true,
318 BridgeState::Connected(bridge) => force_show_panics,
315 }); 319 });
316 if !hide { 320 if show {
317 prev(info) 321 prev(info)
318 } 322 }
319 })); 323 }));