aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_db/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_db/src/lib.rs')
-rw-r--r--crates/ra_db/src/lib.rs18
1 files changed, 4 insertions, 14 deletions
diff --git a/crates/ra_db/src/lib.rs b/crates/ra_db/src/lib.rs
index 78f2cbf12..1f7c9187b 100644
--- a/crates/ra_db/src/lib.rs
+++ b/crates/ra_db/src/lib.rs
@@ -1,27 +1,17 @@
1//! ra_db defines basic database traits. Concrete DB is defined by ra_analysis. 1//! ra_db defines basic database traits. Concrete DB is defined by ra_analysis.
2mod cancelation;
2mod syntax_ptr; 3mod syntax_ptr;
3mod input; 4mod input;
4mod loc2id; 5mod loc2id;
5pub mod mock; 6pub mod mock;
6 7
7use std::sync::Arc; 8use std::sync::Arc;
9
8use ra_editor::LineIndex; 10use ra_editor::LineIndex;
9use ra_syntax::{TextUnit, SourceFileNode}; 11use ra_syntax::{TextUnit, SourceFileNode};
10 12
11#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
12pub struct Canceled;
13
14pub type Cancelable<T> = Result<T, Canceled>;
15
16impl std::fmt::Display for Canceled {
17 fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
18 fmt.write_str("canceled")
19 }
20}
21
22impl std::error::Error for Canceled {}
23
24pub use crate::{ 13pub use crate::{
14 cancelation::{Canceled, Cancelable},
25 syntax_ptr::LocalSyntaxPtr, 15 syntax_ptr::LocalSyntaxPtr,
26 input::{ 16 input::{
27 FilesDatabase, FileId, CrateId, SourceRoot, SourceRootId, CrateGraph, 17 FilesDatabase, FileId, CrateId, SourceRoot, SourceRootId, CrateGraph,
@@ -48,7 +38,7 @@ macro_rules! impl_numeric_id {
48pub trait BaseDatabase: salsa::Database { 38pub trait BaseDatabase: salsa::Database {
49 fn check_canceled(&self) -> Cancelable<()> { 39 fn check_canceled(&self) -> Cancelable<()> {
50 if self.salsa_runtime().is_current_revision_canceled() { 40 if self.salsa_runtime().is_current_revision_canceled() {
51 Err(Canceled) 41 Err(Canceled::new())
52 } else { 42 } else {
53 Ok(()) 43 Ok(())
54 } 44 }