Skip to content

Commit

Permalink
Assert that DB is unwind-safe, instead of proving
Browse files Browse the repository at this point in the history
Unfortunately, that `: RefUnwindSafe` bound gives rustc a hard time,
so let's remove it for know.

See

* #1283
* rust-lang/rust#60444
* rust-lang/rust#58291

closes #1283
  • Loading branch information
matklad committed May 18, 2019
1 parent f711237 commit fcffa6b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions crates/ra_db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub use crate::{
},
};

pub trait CheckCanceled: panic::RefUnwindSafe {
pub trait CheckCanceled {
/// Aborts current query if there are pending changes.
///
/// rust-analyzer needs to be able to answer semantic questions about the
Expand All @@ -36,14 +36,15 @@ pub trait CheckCanceled: panic::RefUnwindSafe {
Self: Sized,
F: FnOnce(&Self) -> T + panic::UnwindSafe,
{
panic::catch_unwind(|| f(self)).map_err(|err| match err.downcast::<Canceled>() {
let this = panic::AssertUnwindSafe(self);
panic::catch_unwind(|| f(*this)).map_err(|err| match err.downcast::<Canceled>() {
Ok(canceled) => *canceled,
Err(payload) => panic::resume_unwind(payload),
})
}
}

impl<T: salsa::Database + panic::RefUnwindSafe> CheckCanceled for T {
impl<T: salsa::Database> CheckCanceled for T {
fn check_canceled(&self) {
if self.salsa_runtime().is_current_revision_canceled() {
Canceled::throw()
Expand Down

0 comments on commit fcffa6b

Please sign in to comment.