mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-10 15:14:32 +00:00
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:
parent
dee7c3b0de
commit
0a8d085619
4 changed files with 5 additions and 48 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -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",
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in a new issue