From 1a74f25f9026f152fdba6f85ec617c02205d98eb Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 23 Oct 2020 15:18:33 +0200 Subject: Fix panic context --- crates/rust-analyzer/src/dispatch.rs | 6 +++--- crates/stdx/src/panic_context.rs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/rust-analyzer/src/dispatch.rs b/crates/rust-analyzer/src/dispatch.rs index 9c8815e29..7a87515e9 100644 --- a/crates/rust-analyzer/src/dispatch.rs +++ b/crates/rust-analyzer/src/dispatch.rs @@ -34,7 +34,7 @@ impl<'a> RequestDispatcher<'a> { }; let world = panic::AssertUnwindSafe(&mut *self.global_state); let response = panic::catch_unwind(move || { - stdx::panic_context::enter(format!("request: {} {:#?}", R::METHOD, params)); + let _pctx = stdx::panic_context::enter(format!("request: {} {:#?}", R::METHOD, params)); let result = f(world.0, params); result_to_response::(id, result) }) @@ -64,7 +64,7 @@ impl<'a> RequestDispatcher<'a> { let world = self.global_state.snapshot(); move || { - let _ctx = + let _pctx = stdx::panic_context::enter(format!("request: {} {:#?}", R::METHOD, params)); let result = f(world, params); Task::Response(result_to_response::(id, result)) @@ -160,7 +160,7 @@ impl<'a> NotificationDispatcher<'a> { return Ok(self); } }; - stdx::panic_context::enter(format!("notification: {}", N::METHOD)); + let _pctx = stdx::panic_context::enter(format!("notification: {}", N::METHOD)); f(self.global_state, params)?; Ok(self) } diff --git a/crates/stdx/src/panic_context.rs b/crates/stdx/src/panic_context.rs index fd232e0cc..8d51e20d3 100644 --- a/crates/stdx/src/panic_context.rs +++ b/crates/stdx/src/panic_context.rs @@ -4,7 +4,7 @@ use std::{cell::RefCell, panic, sync::Once}; -pub fn enter(context: String) -> impl Drop { +pub fn enter(context: String) -> PanicContext { static ONCE: Once = Once::new(); ONCE.call_once(PanicContext::init); @@ -13,7 +13,7 @@ pub fn enter(context: String) -> impl Drop { } #[must_use] -struct PanicContext { +pub struct PanicContext { _priv: (), } -- cgit v1.2.3