aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock8
-rw-r--r--Cargo.toml1
-rw-r--r--crates/ra_db/src/lib.rs22
3 files changed, 20 insertions, 11 deletions
diff --git a/Cargo.lock b/Cargo.lock
index b3172dc28..d2d37f0c7 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -661,7 +661,7 @@ dependencies = [
661 "ra_syntax 0.1.0", 661 "ra_syntax 0.1.0",
662 "relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", 662 "relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
663 "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", 663 "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
664 "salsa 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", 664 "salsa 0.9.1",
665 "test_utils 0.1.0", 665 "test_utils 0.1.0",
666] 666]
667 667
@@ -680,7 +680,7 @@ dependencies = [
680 "ra_syntax 0.1.0", 680 "ra_syntax 0.1.0",
681 "relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", 681 "relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
682 "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", 682 "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
683 "salsa 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", 683 "salsa 0.9.1",
684 "test_utils 0.1.0", 684 "test_utils 0.1.0",
685] 685]
686 686
@@ -700,7 +700,7 @@ dependencies = [
700 "rayon 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", 700 "rayon 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
701 "relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", 701 "relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
702 "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", 702 "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
703 "salsa 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", 703 "salsa 0.9.1",
704 "test_utils 0.1.0", 704 "test_utils 0.1.0",
705 "unicase 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", 705 "unicase 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
706] 706]
@@ -1030,7 +1030,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1030[[package]] 1030[[package]]
1031name = "salsa" 1031name = "salsa"
1032version = "0.9.1" 1032version = "0.9.1"
1033source = "registry+https://github.com/rust-lang/crates.io-index"
1034dependencies = [ 1033dependencies = [
1035 "derive-new 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", 1034 "derive-new 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
1036 "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", 1035 "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1587,7 +1586,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1587"checksum rusty-fork 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9591f190d2852720b679c21f66ad929f9f1d7bb09d1193c26167586029d8489c" 1586"checksum rusty-fork 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9591f190d2852720b679c21f66ad929f9f1d7bb09d1193c26167586029d8489c"
1588"checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7" 1587"checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7"
1589"checksum safemem 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8dca453248a96cb0749e36ccdfe2b0b4e54a61bfef89fb97ec621eb8e0a93dd9" 1588"checksum safemem 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8dca453248a96cb0749e36ccdfe2b0b4e54a61bfef89fb97ec621eb8e0a93dd9"
1590"checksum salsa 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "442ef4acdb48c0e24ddaf4f3b62555af2d1da7047f2f26acd54ae73010aa0c02"
1591"checksum same-file 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8f20c4be53a8a1ff4c1f1b2bd14570d2f634628709752f0702ecdd2b3f9a5267" 1589"checksum same-file 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8f20c4be53a8a1ff4c1f1b2bd14570d2f634628709752f0702ecdd2b3f9a5267"
1592"checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" 1590"checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27"
1593"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" 1591"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
diff --git a/Cargo.toml b/Cargo.toml
index 1cf83dfa8..57896078e 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -7,3 +7,4 @@ debug = true
7 7
8[patch.'crates-io'] 8[patch.'crates-io']
9cargo_metadata = { git = "https://github.com/oli-obk/cargo_metadata.git", rev="f73e27b24e" } 9cargo_metadata = { git = "https://github.com/oli-obk/cargo_metadata.git", rev="f73e27b24e" }
10salsa = { path = "/home/matklad/projects/salsa" }
diff --git a/crates/ra_db/src/lib.rs b/crates/ra_db/src/lib.rs
index fb8ea2496..abe6430fb 100644
--- a/crates/ra_db/src/lib.rs
+++ b/crates/ra_db/src/lib.rs
@@ -5,6 +5,8 @@ mod input;
5mod loc2id; 5mod loc2id;
6pub mod mock; 6pub mod mock;
7 7
8use std::panic;
9
8use ra_syntax::{TextUnit, TextRange, SourceFile, TreePtr}; 10use ra_syntax::{TextUnit, TextRange, SourceFile, TreePtr};
9 11
10pub use crate::{ 12pub use crate::{
@@ -18,13 +20,21 @@ pub use crate::{
18 loc2id::LocationIntener, 20 loc2id::LocationIntener,
19}; 21};
20 22
21pub trait BaseDatabase: salsa::Database { 23pub trait BaseDatabase: salsa::Database + panic::RefUnwindSafe {
22 fn check_canceled(&self) -> Cancelable<()> { 24 fn check_canceled(&self) -> Cancelable<()> {
23 if self.salsa_runtime().is_current_revision_canceled() { 25 self.salsa_runtime()
24 Err(Canceled::new()) 26 .unwind_if_current_revision_is_canceled();
25 } else { 27 Ok(())
26 Ok(()) 28 }
27 } 29
30 fn catch_canceled<F: FnOnce(&Self) -> T + panic::UnwindSafe, T>(
31 &self,
32 f: F,
33 ) -> Result<T, Canceled> {
34 panic::catch_unwind(|| f(self)).map_err(|err| match err.downcast::<salsa::Canceled>() {
35 Ok(_) => Canceled::new(),
36 Err(payload) => panic::resume_unwind(payload),
37 })
28 } 38 }
29} 39}
30 40