From 8eea10e3ab25111375a95990b93d1170d5fe8a9f Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 20 Oct 2018 22:35:55 +0300 Subject: actually check for cancelation --- crates/ra_analysis/src/db.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'crates/ra_analysis/src/db.rs') diff --git a/crates/ra_analysis/src/db.rs b/crates/ra_analysis/src/db.rs index d621b3b22..09d74b9e7 100644 --- a/crates/ra_analysis/src/db.rs +++ b/crates/ra_analysis/src/db.rs @@ -10,7 +10,8 @@ use rustc_hash::FxHashSet; use salsa; use crate::{ - Cancelable, + db, + Cancelable, Canceled, module_map::{ModuleDescriptorQuery, ModuleTreeQuery, ModulesDatabase}, symbol_index::SymbolIndex, FileId, FileResolverImp, @@ -33,6 +34,14 @@ impl salsa::Database for RootDatabase { } } +pub(crate) fn check_canceled(db: &impl salsa::Database) -> Cancelable<()> { + if db.salsa_runtime().is_current_revision_canceled() { + Err(Canceled) + } else { + Ok(()) + } +} + impl salsa::ParallelDatabase for RootDatabase { fn fork(&self) -> Self { RootDatabase { @@ -115,6 +124,7 @@ fn file_lines(db: &impl SyntaxDatabase, file_id: FileId) -> Arc { Arc::new(LineIndex::new(&*text)) } fn file_symbols(db: &impl SyntaxDatabase, file_id: FileId) -> Cancelable> { + db::check_canceled(db)?; let syntax = db.file_syntax(file_id); Ok(Arc::new(SymbolIndex::for_file(file_id, syntax))) } -- cgit v1.2.3