diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-12-30 21:39:50 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-12-30 21:39:50 +0000 |
commit | e2816a95e94eb59fc875295ce7f3f547e95fe7b1 (patch) | |
tree | ed180196ff6cfc2cfa7dd71f0728decbccbd11b2 /crates/ra_db/src | |
parent | dee7c3b0de9650216bd761e587d0e1d4cca52981 (diff) | |
parent | 0a8d085619674cd113b6dd903d22233a07fe4839 (diff) |
Merge #380
380: no-backtrace r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_db/src')
-rw-r--r-- | crates/ra_db/src/cancelation.rs | 49 |
1 files changed, 4 insertions, 45 deletions
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 | } | ||