diff options
Diffstat (limited to 'crates/ra_db/src/lib.rs')
-rw-r--r-- | crates/ra_db/src/lib.rs | 18 |
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. |
2 | mod cancelation; | ||
2 | mod syntax_ptr; | 3 | mod syntax_ptr; |
3 | mod input; | 4 | mod input; |
4 | mod loc2id; | 5 | mod loc2id; |
5 | pub mod mock; | 6 | pub mod mock; |
6 | 7 | ||
7 | use std::sync::Arc; | 8 | use std::sync::Arc; |
9 | |||
8 | use ra_editor::LineIndex; | 10 | use ra_editor::LineIndex; |
9 | use ra_syntax::{TextUnit, SourceFileNode}; | 11 | use ra_syntax::{TextUnit, SourceFileNode}; |
10 | 12 | ||
11 | #[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] | ||
12 | pub struct Canceled; | ||
13 | |||
14 | pub type Cancelable<T> = Result<T, Canceled>; | ||
15 | |||
16 | impl 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 | |||
22 | impl std::error::Error for Canceled {} | ||
23 | |||
24 | pub use crate::{ | 13 | pub 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 { | |||
48 | pub trait BaseDatabase: salsa::Database { | 38 | pub 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 | } |