From 6bcc1b8b9e9ff90a5c5442dce230dba5995ca5b5 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 29 May 2019 22:13:03 +0300 Subject: add cacellation checks to expensive queries --- crates/ra_hir/src/nameres.rs | 1 + crates/ra_hir/src/nameres/collector.rs | 1 + crates/ra_hir/src/ty/traits.rs | 1 + 3 files changed, 3 insertions(+) (limited to 'crates/ra_hir') diff --git a/crates/ra_hir/src/nameres.rs b/crates/ra_hir/src/nameres.rs index 9b9212bfc..42dcac332 100644 --- a/crates/ra_hir/src/nameres.rs +++ b/crates/ra_hir/src/nameres.rs @@ -222,6 +222,7 @@ fn or(left: ItemOrMacro, right: ItemOrMacro) -> ItemOrMacro { impl CrateDefMap { pub(crate) fn crate_def_map_query(db: &impl DefDatabase, krate: Crate) -> Arc { + db.check_canceled(); let _p = profile("crate_def_map_query"); let def_map = { let edition = krate.edition(db); diff --git a/crates/ra_hir/src/nameres/collector.rs b/crates/ra_hir/src/nameres/collector.rs index ba7ea0017..af8ac064c 100644 --- a/crates/ra_hir/src/nameres/collector.rs +++ b/crates/ra_hir/src/nameres/collector.rs @@ -112,6 +112,7 @@ where // main name resolution fixed-point loop. let mut i = 0; loop { + self.db.check_canceled(); match (self.resolve_imports(), self.resolve_macros()) { (ReachedFixedPoint::Yes, ReachedFixedPoint::Yes) => break, _ => i += 1, diff --git a/crates/ra_hir/src/ty/traits.rs b/crates/ra_hir/src/ty/traits.rs index e6c78c0d4..fc90f56d5 100644 --- a/crates/ra_hir/src/ty/traits.rs +++ b/crates/ra_hir/src/ty/traits.rs @@ -82,6 +82,7 @@ pub(crate) fn implements_query( krate: Crate, trait_ref: Canonical, ) -> Option { + db.check_canceled(); let _p = profile("implements_query"); let goal: chalk_ir::Goal = trait_ref.value.to_chalk(db).cast(); debug!("goal: {:?}", goal); -- cgit v1.2.3