diff options
author | Aleksey Kladov <[email protected]> | 2020-10-23 14:18:33 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-10-23 14:18:33 +0100 |
commit | 1a74f25f9026f152fdba6f85ec617c02205d98eb (patch) | |
tree | 1ea6cbcb393def5f55a80b6aeb17d5ffbb6ec707 | |
parent | 31db677a948cfad7c0651fb3cd45a2cf577bb95f (diff) |
Fix panic context
-rw-r--r-- | crates/rust-analyzer/src/dispatch.rs | 6 | ||||
-rw-r--r-- | 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> { | |||
34 | }; | 34 | }; |
35 | let world = panic::AssertUnwindSafe(&mut *self.global_state); | 35 | let world = panic::AssertUnwindSafe(&mut *self.global_state); |
36 | let response = panic::catch_unwind(move || { | 36 | let response = panic::catch_unwind(move || { |
37 | stdx::panic_context::enter(format!("request: {} {:#?}", R::METHOD, params)); | 37 | let _pctx = stdx::panic_context::enter(format!("request: {} {:#?}", R::METHOD, params)); |
38 | let result = f(world.0, params); | 38 | let result = f(world.0, params); |
39 | result_to_response::<R>(id, result) | 39 | result_to_response::<R>(id, result) |
40 | }) | 40 | }) |
@@ -64,7 +64,7 @@ impl<'a> RequestDispatcher<'a> { | |||
64 | let world = self.global_state.snapshot(); | 64 | let world = self.global_state.snapshot(); |
65 | 65 | ||
66 | move || { | 66 | move || { |
67 | let _ctx = | 67 | let _pctx = |
68 | stdx::panic_context::enter(format!("request: {} {:#?}", R::METHOD, params)); | 68 | stdx::panic_context::enter(format!("request: {} {:#?}", R::METHOD, params)); |
69 | let result = f(world, params); | 69 | let result = f(world, params); |
70 | Task::Response(result_to_response::<R>(id, result)) | 70 | Task::Response(result_to_response::<R>(id, result)) |
@@ -160,7 +160,7 @@ impl<'a> NotificationDispatcher<'a> { | |||
160 | return Ok(self); | 160 | return Ok(self); |
161 | } | 161 | } |
162 | }; | 162 | }; |
163 | stdx::panic_context::enter(format!("notification: {}", N::METHOD)); | 163 | let _pctx = stdx::panic_context::enter(format!("notification: {}", N::METHOD)); |
164 | f(self.global_state, params)?; | 164 | f(self.global_state, params)?; |
165 | Ok(self) | 165 | Ok(self) |
166 | } | 166 | } |
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 @@ | |||
4 | 4 | ||
5 | use std::{cell::RefCell, panic, sync::Once}; | 5 | use std::{cell::RefCell, panic, sync::Once}; |
6 | 6 | ||
7 | pub fn enter(context: String) -> impl Drop { | 7 | pub fn enter(context: String) -> PanicContext { |
8 | static ONCE: Once = Once::new(); | 8 | static ONCE: Once = Once::new(); |
9 | ONCE.call_once(PanicContext::init); | 9 | ONCE.call_once(PanicContext::init); |
10 | 10 | ||
@@ -13,7 +13,7 @@ pub fn enter(context: String) -> impl Drop { | |||
13 | } | 13 | } |
14 | 14 | ||
15 | #[must_use] | 15 | #[must_use] |
16 | struct PanicContext { | 16 | pub struct PanicContext { |
17 | _priv: (), | 17 | _priv: (), |
18 | } | 18 | } |
19 | 19 | ||