380: no-backtrace r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
bors[bot] 2018-12-30 21:39:50 +00:00
commit e2816a95e9
4 changed files with 5 additions and 48 deletions

1
Cargo.lock generated
View file

@ -697,7 +697,6 @@ dependencies = [
name = "ra_db"
version = "0.1.0"
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)",
"ra_editor 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>"]
[dependencies]
backtrace = "0.3.1"
relative-path = "0.4.0"
salsa = "0.9.0"
rustc-hash = "1.0"

View file

@ -15,29 +15,17 @@
//! any background processing (this bit is handled by salsa, see
//! `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.
#[derive(Clone)]
#[derive(Clone, PartialEq, Eq, Hash)]
pub struct Canceled {
backtrace: Arc<Mutex<Backtrace>>,
_private: (),
}
pub type Cancelable<T> = Result<T, Canceled>;
impl Canceled {
pub(crate) fn new() -> Canceled {
let bt = Backtrace::new_unresolved();
Canceled {
backtrace: Arc::new(Mutex::new(bt)),
}
Canceled { _private: () }
}
}
@ -49,37 +37,8 @@ impl std::fmt::Display for Canceled {
impl std::fmt::Debug for Canceled {
fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let mut bt = self.backtrace.lock();
let bt: &mut Backtrace = &mut *bt;
bt.resolve();
write!(fmt, "canceled at:\n{:?}", bt)
write!(fmt, "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(
id,
ErrorCode::ContentModified as i32,
format!("content modified: {:?}", e),
"content modified".to_string(),
)
} else {
RawResponse::err(