diff options
Diffstat (limited to 'crates/ra_db')
-rw-r--r-- | crates/ra_db/src/cancellation.rs | 4 | ||||
-rw-r--r-- | crates/ra_db/src/lib.rs | 9 |
2 files changed, 9 insertions, 4 deletions
diff --git a/crates/ra_db/src/cancellation.rs b/crates/ra_db/src/cancellation.rs index 8d38eebfb..f7077b992 100644 --- a/crates/ra_db/src/cancellation.rs +++ b/crates/ra_db/src/cancellation.rs | |||
@@ -27,6 +27,10 @@ impl Canceled { | |||
27 | pub(crate) fn new() -> Canceled { | 27 | pub(crate) fn new() -> Canceled { |
28 | Canceled { _private: () } | 28 | Canceled { _private: () } |
29 | } | 29 | } |
30 | |||
31 | pub fn throw() -> ! { | ||
32 | std::panic::resume_unwind(Box::new(Canceled::new())) | ||
33 | } | ||
30 | } | 34 | } |
31 | 35 | ||
32 | impl std::fmt::Display for Canceled { | 36 | impl std::fmt::Display for Canceled { |
diff --git a/crates/ra_db/src/lib.rs b/crates/ra_db/src/lib.rs index abe6430fb..00d2d5ae9 100644 --- a/crates/ra_db/src/lib.rs +++ b/crates/ra_db/src/lib.rs | |||
@@ -20,10 +20,10 @@ pub use crate::{ | |||
20 | loc2id::LocationIntener, | 20 | loc2id::LocationIntener, |
21 | }; | 21 | }; |
22 | 22 | ||
23 | pub trait BaseDatabase: salsa::Database + panic::RefUnwindSafe { | 23 | pub trait BaseDatabase: salsa::Database { |
24 | fn check_canceled(&self) -> Cancelable<()> { | 24 | fn check_canceled(&self) -> Cancelable<()> { |
25 | self.salsa_runtime() | 25 | self.salsa_runtime() |
26 | .unwind_if_current_revision_is_canceled(); | 26 | .if_current_revision_is_canceled(Canceled::throw); |
27 | Ok(()) | 27 | Ok(()) |
28 | } | 28 | } |
29 | 29 | ||
@@ -31,8 +31,9 @@ pub trait BaseDatabase: salsa::Database + panic::RefUnwindSafe { | |||
31 | &self, | 31 | &self, |
32 | f: F, | 32 | f: F, |
33 | ) -> Result<T, Canceled> { | 33 | ) -> Result<T, Canceled> { |
34 | panic::catch_unwind(|| f(self)).map_err(|err| match err.downcast::<salsa::Canceled>() { | 34 | let me = panic::AssertUnwindSafe(self); |
35 | Ok(_) => Canceled::new(), | 35 | panic::catch_unwind(|| f(me.0)).map_err(|err| match err.downcast::<Canceled>() { |
36 | Ok(canceled) => *canceled, | ||
36 | Err(payload) => panic::resume_unwind(payload), | 37 | Err(payload) => panic::resume_unwind(payload), |
37 | }) | 38 | }) |
38 | } | 39 | } |