implement RefUnwindSafe

This commit is contained in:
Aleksey Kladov 2019-01-10 13:04:04 +03:00
parent 64455ad701
commit f72c031eb9
4 changed files with 16 additions and 6 deletions

View file

@ -20,7 +20,7 @@ pub use crate::{
loc2id::LocationIntener,
};
pub trait BaseDatabase: salsa::Database {
pub trait BaseDatabase: salsa::Database + panic::RefUnwindSafe {
fn check_canceled(&self) -> Cancelable<()> {
self.salsa_runtime()
.if_current_revision_is_canceled(Canceled::throw);
@ -31,8 +31,7 @@ pub trait BaseDatabase: salsa::Database {
&self,
f: F,
) -> Result<T, Canceled> {
let me = panic::AssertUnwindSafe(self);
panic::catch_unwind(|| f(me.0)).map_err(|err| match err.downcast::<Canceled>() {
panic::catch_unwind(|| f(self)).map_err(|err| match err.downcast::<Canceled>() {
Ok(canceled) => *canceled,
Err(payload) => panic::resume_unwind(payload),
})

View file

@ -1,4 +1,4 @@
use std::hash::Hash;
use std::{panic, hash::Hash};
use parking_lot::Mutex;
use rustc_hash::FxHashMap;
@ -70,6 +70,15 @@ where
map: Mutex<Loc2IdMap<LOC, ID>>,
}
impl<LOC, ID> panic::RefUnwindSafe for LocationIntener<LOC, ID>
where
ID: ArenaId + Clone,
LOC: Clone + Eq + Hash,
ID: panic::RefUnwindSafe,
LOC: panic::RefUnwindSafe,
{
}
impl<LOC, ID> Default for LocationIntener<LOC, ID>
where
ID: ArenaId + Clone,