diff options
author | Aleksey Kladov <[email protected]> | 2019-01-10 10:04:04 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-01-10 10:04:04 +0000 |
commit | f72c031eb9a15f25834a7980008db764ff2867a0 (patch) | |
tree | a3560becba476775f18c996293d6d5892e7611f0 /crates/ra_db | |
parent | 64455ad701c8bce6e35793042f5e2ec177e12f7e (diff) |
implement RefUnwindSafe
Diffstat (limited to 'crates/ra_db')
-rw-r--r-- | crates/ra_db/src/lib.rs | 5 | ||||
-rw-r--r-- | crates/ra_db/src/loc2id.rs | 11 |
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 | ||
23 | pub trait BaseDatabase: salsa::Database { | 23 | pub 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 @@ | |||
1 | use std::hash::Hash; | 1 | use std::{panic, hash::Hash}; |
2 | 2 | ||
3 | use parking_lot::Mutex; | 3 | use parking_lot::Mutex; |
4 | use rustc_hash::FxHashMap; | 4 | use rustc_hash::FxHashMap; |
@@ -70,6 +70,15 @@ where | |||
70 | map: Mutex<Loc2IdMap<LOC, ID>>, | 70 | map: Mutex<Loc2IdMap<LOC, ID>>, |
71 | } | 71 | } |
72 | 72 | ||
73 | impl<LOC, ID> panic::RefUnwindSafe for LocationIntener<LOC, ID> | ||
74 | where | ||
75 | ID: ArenaId + Clone, | ||
76 | LOC: Clone + Eq + Hash, | ||
77 | ID: panic::RefUnwindSafe, | ||
78 | LOC: panic::RefUnwindSafe, | ||
79 | { | ||
80 | } | ||
81 | |||
73 | impl<LOC, ID> Default for LocationIntener<LOC, ID> | 82 | impl<LOC, ID> Default for LocationIntener<LOC, ID> |
74 | where | 83 | where |
75 | ID: ArenaId + Clone, | 84 | ID: ArenaId + Clone, |