remove backtraces from Cancelled

Hopefully we won't need them for debugging. If we do need them, it
should be easy to add back.
This commit is contained in:
Aleksey Kladov 2018-12-31 00:38:50 +03:00
parent dee7c3b0de
commit 0a8d085619
4 changed files with 5 additions and 48 deletions

1
Cargo.lock generated
View file

@ -697,7 +697,6 @@ dependencies = [
name = "ra_db" name = "ra_db"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"backtrace 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ra_editor 0.1.0", "ra_editor 0.1.0",
"ra_syntax 0.1.0", "ra_syntax 0.1.0",

View file

@ -5,7 +5,6 @@ version = "0.1.0"
authors = ["Aleksey Kladov <aleksey.kladov@gmail.com>"] authors = ["Aleksey Kladov <aleksey.kladov@gmail.com>"]
[dependencies] [dependencies]
backtrace = "0.3.1"
relative-path = "0.4.0" relative-path = "0.4.0"
salsa = "0.9.0" salsa = "0.9.0"
rustc-hash = "1.0" rustc-hash = "1.0"

View file

@ -15,29 +15,17 @@
//! any background processing (this bit is handled by salsa, see //! any background processing (this bit is handled by salsa, see
//! `BaseDatabase::check_canceled` method). //! `BaseDatabase::check_canceled` method).
use std::{
cmp,
hash::{Hash, Hasher},
sync::Arc,
};
use backtrace::Backtrace;
use parking_lot::Mutex;
/// An "error" signifing that the operation was canceled. /// An "error" signifing that the operation was canceled.
#[derive(Clone)] #[derive(Clone, PartialEq, Eq, Hash)]
pub struct Canceled { pub struct Canceled {
backtrace: Arc<Mutex<Backtrace>>, _private: (),
} }
pub type Cancelable<T> = Result<T, Canceled>; pub type Cancelable<T> = Result<T, Canceled>;
impl Canceled { impl Canceled {
pub(crate) fn new() -> Canceled { pub(crate) fn new() -> Canceled {
let bt = Backtrace::new_unresolved(); Canceled { _private: () }
Canceled {
backtrace: Arc::new(Mutex::new(bt)),
}
} }
} }
@ -49,37 +37,8 @@ impl std::fmt::Display for Canceled {
impl std::fmt::Debug for Canceled { impl std::fmt::Debug for Canceled {
fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let mut bt = self.backtrace.lock(); write!(fmt, "Canceled")
let bt: &mut Backtrace = &mut *bt;
bt.resolve();
write!(fmt, "canceled at:\n{:?}", bt)
} }
} }
impl std::error::Error for Canceled {} impl std::error::Error for Canceled {}
impl PartialEq for Canceled {
fn eq(&self, _: &Canceled) -> bool {
true
}
}
impl Eq for Canceled {}
impl Hash for Canceled {
fn hash<H: Hasher>(&self, hasher: &mut H) {
().hash(hasher)
}
}
impl cmp::Ord for Canceled {
fn cmp(&self, _: &Canceled) -> cmp::Ordering {
cmp::Ordering::Equal
}
}
impl cmp::PartialOrd for Canceled {
fn partial_cmp(&self, other: &Canceled) -> Option<cmp::Ordering> {
Some(self.cmp(other))
}
}

View file

@ -432,7 +432,7 @@ impl<'a> PoolDispatcher<'a> {
RawResponse::err( RawResponse::err(
id, id,
ErrorCode::ContentModified as i32, ErrorCode::ContentModified as i32,
format!("content modified: {:?}", e), "content modified".to_string(),
) )
} else { } else {
RawResponse::err( RawResponse::err(