diff options
Diffstat (limited to 'crates/ra_db')
-rw-r--r-- | crates/ra_db/Cargo.toml | 1 | ||||
-rw-r--r-- | crates/ra_db/src/cancelation.rs | 49 |
2 files changed, 4 insertions, 46 deletions
diff --git a/crates/ra_db/Cargo.toml b/crates/ra_db/Cargo.toml index 75bcf2b39..ecc56d953 100644 --- a/crates/ra_db/Cargo.toml +++ b/crates/ra_db/Cargo.toml | |||
@@ -5,7 +5,6 @@ version = "0.1.0" | |||
5 | authors = ["Aleksey Kladov <[email protected]>"] | 5 | authors = ["Aleksey Kladov <[email protected]>"] |
6 | 6 | ||
7 | [dependencies] | 7 | [dependencies] |
8 | backtrace = "0.3.1" | ||
9 | relative-path = "0.4.0" | 8 | relative-path = "0.4.0" |
10 | salsa = "0.9.0" | 9 | salsa = "0.9.0" |
11 | rustc-hash = "1.0" | 10 | rustc-hash = "1.0" |
diff --git a/crates/ra_db/src/cancelation.rs b/crates/ra_db/src/cancelation.rs index 73444b015..56ce27bff 100644 --- a/crates/ra_db/src/cancelation.rs +++ b/crates/ra_db/src/cancelation.rs | |||
@@ -15,29 +15,17 @@ | |||
15 | //! any background processing (this bit is handled by salsa, see | 15 | //! any background processing (this bit is handled by salsa, see |
16 | //! `BaseDatabase::check_canceled` method). | 16 | //! `BaseDatabase::check_canceled` method). |
17 | 17 | ||
18 | use std::{ | ||
19 | cmp, | ||
20 | hash::{Hash, Hasher}, | ||
21 | sync::Arc, | ||
22 | }; | ||
23 | |||
24 | use backtrace::Backtrace; | ||
25 | use parking_lot::Mutex; | ||
26 | |||
27 | /// An "error" signifing that the operation was canceled. | 18 | /// An "error" signifing that the operation was canceled. |
28 | #[derive(Clone)] | 19 | #[derive(Clone, PartialEq, Eq, Hash)] |
29 | pub struct Canceled { | 20 | pub struct Canceled { |
30 | backtrace: Arc<Mutex<Backtrace>>, | 21 | _private: (), |
31 | } | 22 | } |
32 | 23 | ||
33 | pub type Cancelable<T> = Result<T, Canceled>; | 24 | pub type Cancelable<T> = Result<T, Canceled>; |
34 | 25 | ||
35 | impl Canceled { | 26 | impl Canceled { |
36 | pub(crate) fn new() -> Canceled { | 27 | pub(crate) fn new() -> Canceled { |
37 | let bt = Backtrace::new_unresolved(); | 28 | Canceled { _private: () } |
38 | Canceled { | ||
39 | backtrace: Arc::new(Mutex::new(bt)), | ||
40 | } | ||
41 | } | 29 | } |
42 | } | 30 | } |
43 | 31 | ||
@@ -49,37 +37,8 @@ impl std::fmt::Display for Canceled { | |||
49 | 37 | ||
50 | impl std::fmt::Debug for Canceled { | 38 | impl std::fmt::Debug for Canceled { |
51 | fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 39 | fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
52 | let mut bt = self.backtrace.lock(); | 40 | write!(fmt, "Canceled") |
53 | let bt: &mut Backtrace = &mut *bt; | ||
54 | bt.resolve(); | ||
55 | write!(fmt, "canceled at:\n{:?}", bt) | ||
56 | } | 41 | } |
57 | } | 42 | } |
58 | 43 | ||
59 | impl std::error::Error for Canceled {} | 44 | impl std::error::Error for Canceled {} |
60 | |||
61 | impl PartialEq for Canceled { | ||
62 | fn eq(&self, _: &Canceled) -> bool { | ||
63 | true | ||
64 | } | ||
65 | } | ||
66 | |||
67 | impl Eq for Canceled {} | ||
68 | |||
69 | impl Hash for Canceled { | ||
70 | fn hash<H: Hasher>(&self, hasher: &mut H) { | ||
71 | ().hash(hasher) | ||
72 | } | ||
73 | } | ||
74 | |||
75 | impl cmp::Ord for Canceled { | ||
76 | fn cmp(&self, _: &Canceled) -> cmp::Ordering { | ||
77 | cmp::Ordering::Equal | ||
78 | } | ||
79 | } | ||
80 | |||
81 | impl cmp::PartialOrd for Canceled { | ||
82 | fn partial_cmp(&self, other: &Canceled) -> Option<cmp::Ordering> { | ||
83 | Some(self.cmp(other)) | ||
84 | } | ||
85 | } | ||