mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-23 19:43:23 +00:00
implement RefUnwindSafe
This commit is contained in:
parent
64455ad701
commit
f72c031eb9
4 changed files with 16 additions and 6 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -1024,7 +1024,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
[[package]]
|
||||
name = "salsa"
|
||||
version = "0.9.1"
|
||||
source = "git+https://github.com/matklad/salsa?branch=panic-hooks#add15d83eaa865571cd33e60b2eb611a366ca3ff"
|
||||
source = "git+https://github.com/matklad/salsa?branch=panic-hooks#a17757bbaaadeed4839366745b848d66ac991cd0"
|
||||
dependencies = [
|
||||
"derive-new 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
|
@ -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),
|
||||
})
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use std::sync::Arc;
|
||||
use std::{sync::Arc, panic};
|
||||
|
||||
use parking_lot::Mutex;
|
||||
use salsa::{self, Database};
|
||||
|
@ -18,6 +18,8 @@ pub(crate) struct MockDatabase {
|
|||
file_counter: u32,
|
||||
}
|
||||
|
||||
impl panic::RefUnwindSafe for MockDatabase {}
|
||||
|
||||
impl MockDatabase {
|
||||
pub(crate) fn with_files(fixture: &str) -> (MockDatabase, SourceRoot) {
|
||||
let (db, source_root, position) = MockDatabase::from_fixture(fixture);
|
||||
|
|
Loading…
Reference in a new issue