aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_db/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_db/src/lib.rs')
-rw-r--r--crates/ra_db/src/lib.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/crates/ra_db/src/lib.rs b/crates/ra_db/src/lib.rs
index 1cd400752..bf567721a 100644
--- a/crates/ra_db/src/lib.rs
+++ b/crates/ra_db/src/lib.rs
@@ -15,7 +15,7 @@ pub use crate::{
15 }, 15 },
16}; 16};
17 17
18pub trait CheckCanceled: panic::RefUnwindSafe { 18pub trait CheckCanceled {
19 /// Aborts current query if there are pending changes. 19 /// Aborts current query if there are pending changes.
20 /// 20 ///
21 /// rust-analyzer needs to be able to answer semantic questions about the 21 /// rust-analyzer needs to be able to answer semantic questions about the
@@ -36,14 +36,15 @@ pub trait CheckCanceled: panic::RefUnwindSafe {
36 Self: Sized, 36 Self: Sized,
37 F: FnOnce(&Self) -> T + panic::UnwindSafe, 37 F: FnOnce(&Self) -> T + panic::UnwindSafe,
38 { 38 {
39 panic::catch_unwind(|| f(self)).map_err(|err| match err.downcast::<Canceled>() { 39 let this = panic::AssertUnwindSafe(self);
40 panic::catch_unwind(|| f(*this)).map_err(|err| match err.downcast::<Canceled>() {
40 Ok(canceled) => *canceled, 41 Ok(canceled) => *canceled,
41 Err(payload) => panic::resume_unwind(payload), 42 Err(payload) => panic::resume_unwind(payload),
42 }) 43 })
43 } 44 }
44} 45}
45 46
46impl<T: salsa::Database + panic::RefUnwindSafe> CheckCanceled for T { 47impl<T: salsa::Database> CheckCanceled for T {
47 fn check_canceled(&self) { 48 fn check_canceled(&self) {
48 if self.salsa_runtime().is_current_revision_canceled() { 49 if self.salsa_runtime().is_current_revision_canceled() {
49 Canceled::throw() 50 Canceled::throw()