aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2018-12-30 21:39:50 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2018-12-30 21:39:50 +0000
commite2816a95e94eb59fc875295ce7f3f547e95fe7b1 (patch)
treeed180196ff6cfc2cfa7dd71f0728decbccbd11b2 /crates
parentdee7c3b0de9650216bd761e587d0e1d4cca52981 (diff)
parent0a8d085619674cd113b6dd903d22233a07fe4839 (diff)
Merge #380
380: no-backtrace r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_db/Cargo.toml1
-rw-r--r--crates/ra_db/src/cancelation.rs49
-rw-r--r--crates/ra_lsp_server/src/main_loop.rs2
3 files changed, 5 insertions, 47 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"
5authors = ["Aleksey Kladov <[email protected]>"] 5authors = ["Aleksey Kladov <[email protected]>"]
6 6
7[dependencies] 7[dependencies]
8backtrace = "0.3.1"
9relative-path = "0.4.0" 8relative-path = "0.4.0"
10salsa = "0.9.0" 9salsa = "0.9.0"
11rustc-hash = "1.0" 10rustc-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
18use std::{
19 cmp,
20 hash::{Hash, Hasher},
21 sync::Arc,
22};
23
24use backtrace::Backtrace;
25use 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)]
29pub struct Canceled { 20pub struct Canceled {
30 backtrace: Arc<Mutex<Backtrace>>, 21 _private: (),
31} 22}
32 23
33pub type Cancelable<T> = Result<T, Canceled>; 24pub type Cancelable<T> = Result<T, Canceled>;
34 25
35impl Canceled { 26impl 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
50impl std::fmt::Debug for Canceled { 38impl 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
59impl std::error::Error for Canceled {} 44impl std::error::Error for Canceled {}
60
61impl PartialEq for Canceled {
62 fn eq(&self, _: &Canceled) -> bool {
63 true
64 }
65}
66
67impl Eq for Canceled {}
68
69impl Hash for Canceled {
70 fn hash<H: Hasher>(&self, hasher: &mut H) {
71 ().hash(hasher)
72 }
73}
74
75impl cmp::Ord for Canceled {
76 fn cmp(&self, _: &Canceled) -> cmp::Ordering {
77 cmp::Ordering::Equal
78 }
79}
80
81impl cmp::PartialOrd for Canceled {
82 fn partial_cmp(&self, other: &Canceled) -> Option<cmp::Ordering> {
83 Some(self.cmp(other))
84 }
85}
diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs
index 3ebae4ecd..d425b6733 100644
--- a/crates/ra_lsp_server/src/main_loop.rs
+++ b/crates/ra_lsp_server/src/main_loop.rs
@@ -432,7 +432,7 @@ impl<'a> PoolDispatcher<'a> {
432 RawResponse::err( 432 RawResponse::err(
433 id, 433 id,
434 ErrorCode::ContentModified as i32, 434 ErrorCode::ContentModified as i32,
435 format!("content modified: {:?}", e), 435 "content modified".to_string(),
436 ) 436 )
437 } else { 437 } else {
438 RawResponse::err( 438 RawResponse::err(