aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock2
-rw-r--r--crates/ra_db/src/lib.rs5
-rw-r--r--crates/ra_db/src/loc2id.rs11
-rw-r--r--crates/ra_hir/src/mock.rs4
4 files changed, 16 insertions, 6 deletions
diff --git a/Cargo.lock b/Cargo.lock
index eb053a09c..74e9d0e6e 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1024,7 +1024,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1024[[package]] 1024[[package]]
1025name = "salsa" 1025name = "salsa"
1026version = "0.9.1" 1026version = "0.9.1"
1027source = "git+https://github.com/matklad/salsa?branch=panic-hooks#add15d83eaa865571cd33e60b2eb611a366ca3ff" 1027source = "git+https://github.com/matklad/salsa?branch=panic-hooks#a17757bbaaadeed4839366745b848d66ac991cd0"
1028dependencies = [ 1028dependencies = [
1029 "derive-new 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", 1029 "derive-new 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
1030 "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", 1030 "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
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,
diff --git a/crates/ra_hir/src/mock.rs b/crates/ra_hir/src/mock.rs
index 0fae7de82..7a0301648 100644
--- a/crates/ra_hir/src/mock.rs
+++ b/crates/ra_hir/src/mock.rs
@@ -1,4 +1,4 @@
1use std::sync::Arc; 1use std::{sync::Arc, panic};
2 2
3use parking_lot::Mutex; 3use parking_lot::Mutex;
4use salsa::{self, Database}; 4use salsa::{self, Database};
@@ -18,6 +18,8 @@ pub(crate) struct MockDatabase {
18 file_counter: u32, 18 file_counter: u32,
19} 19}
20 20
21impl panic::RefUnwindSafe for MockDatabase {}
22
21impl MockDatabase { 23impl MockDatabase {
22 pub(crate) fn with_files(fixture: &str) -> (MockDatabase, SourceRoot) { 24 pub(crate) fn with_files(fixture: &str) -> (MockDatabase, SourceRoot) {
23 let (db, source_root, position) = MockDatabase::from_fixture(fixture); 25 let (db, source_root, position) = MockDatabase::from_fixture(fixture);