aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_db
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-01-10 10:04:04 +0000
committerAleksey Kladov <[email protected]>2019-01-10 10:04:04 +0000
commitf72c031eb9a15f25834a7980008db764ff2867a0 (patch)
treea3560becba476775f18c996293d6d5892e7611f0 /crates/ra_db
parent64455ad701c8bce6e35793042f5e2ec177e12f7e (diff)
implement RefUnwindSafe
Diffstat (limited to 'crates/ra_db')
-rw-r--r--crates/ra_db/src/lib.rs5
-rw-r--r--crates/ra_db/src/loc2id.rs11
2 files changed, 12 insertions, 4 deletions
diff --git a/crates/ra_db/src/lib.rs b/crates/ra_db/src/lib.rs
index 00d2d5ae9..20e712afe 100644
--- a/crates/ra_db/src/lib.rs
+++ b/crates/ra_db/src/lib.rs
@@ -20,7 +20,7 @@ pub use crate::{
20 loc2id::LocationIntener, 20 loc2id::LocationIntener,
21}; 21};
22 22
23pub trait BaseDatabase: salsa::Database { 23pub trait BaseDatabase: salsa::Database + panic::RefUnwindSafe {
24 fn check_canceled(&self) -> Cancelable<()> { 24 fn check_canceled(&self) -> Cancelable<()> {
25 self.salsa_runtime() 25 self.salsa_runtime()
26 .if_current_revision_is_canceled(Canceled::throw); 26 .if_current_revision_is_canceled(Canceled::throw);
@@ -31,8 +31,7 @@ pub trait BaseDatabase: salsa::Database {
31 &self, 31 &self,
32 f: F, 32 f: F,
33 ) -> Result<T, Canceled> { 33 ) -> Result<T, Canceled> {
34 let me = panic::AssertUnwindSafe(self); 34 panic::catch_unwind(|| f(self)).map_err(|err| match err.downcast::<Canceled>() {
35 panic::catch_unwind(|| f(me.0)).map_err(|err| match err.downcast::<Canceled>() {
36 Ok(canceled) => *canceled, 35 Ok(canceled) => *canceled,
37 Err(payload) => panic::resume_unwind(payload), 36 Err(payload) => panic::resume_unwind(payload),
38 }) 37 })
diff --git a/crates/ra_db/src/loc2id.rs b/crates/ra_db/src/loc2id.rs
index 254c52629..359cd893d 100644
--- a/crates/ra_db/src/loc2id.rs
+++ b/crates/ra_db/src/loc2id.rs
@@ -1,4 +1,4 @@
1use std::hash::Hash; 1use std::{panic, hash::Hash};
2 2
3use parking_lot::Mutex; 3use parking_lot::Mutex;
4use rustc_hash::FxHashMap; 4use rustc_hash::FxHashMap;
@@ -70,6 +70,15 @@ where
70 map: Mutex<Loc2IdMap<LOC, ID>>, 70 map: Mutex<Loc2IdMap<LOC, ID>>,
71} 71}
72 72
73impl<LOC, ID> panic::RefUnwindSafe for LocationIntener<LOC, ID>
74where
75 ID: ArenaId + Clone,
76 LOC: Clone + Eq + Hash,
77 ID: panic::RefUnwindSafe,
78 LOC: panic::RefUnwindSafe,
79{
80}
81
73impl<LOC, ID> Default for LocationIntener<LOC, ID> 82impl<LOC, ID> Default for LocationIntener<LOC, ID>
74where 83where
75 ID: ArenaId + Clone, 84 ID: ArenaId + Clone,