aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-05-30 08:11:08 +0100
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-05-30 08:11:08 +0100
commite02d90f8f93ba9b856324abdc883166d16a6ad87 (patch)
tree2cb254aa6164b722bdc556bb79f18f71b92e9211
parent8c3cd8f121d4306732423d1c8804d54e36bd706a (diff)
parent0ee5bd16c9e92b3a17a8f5cc79b0cb6a44ef8a10 (diff)
Merge #1348
1348: cancel salsa's validation r=matklad a=matklad This small fix should improve rust-analyzer resopnsivness for real-time operations like onEnter handling. Turns out, salsa's validation can take hundreds of milliseconds, and, in case no changes were made, it won't be triggering any queries. Because we check for cancellation in queries, that means that validation is not cancellable! What this PR does is injecting check_canceled checks into validation, by using salsa's event API, which wasn't meant to be used like this, but, hey, it works! Here's the onEnter handling before and after this change: https://youtu.be/7-ffPzgvH7o Co-authored-by: Aleksey Kladov <[email protected]>
-rw-r--r--crates/ra_ide_api/src/db.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/crates/ra_ide_api/src/db.rs b/crates/ra_ide_api/src/db.rs
index 33d3903bb..d84a0e7be 100644
--- a/crates/ra_ide_api/src/db.rs
+++ b/crates/ra_ide_api/src/db.rs
@@ -31,6 +31,11 @@ impl salsa::Database for RootDatabase {
31 fn on_propagated_panic(&self) -> ! { 31 fn on_propagated_panic(&self) -> ! {
32 Canceled::throw() 32 Canceled::throw()
33 } 33 }
34 fn salsa_event(&self, event: impl Fn() -> salsa::Event<RootDatabase>) {
35 if let salsa::EventKind::DidValidateMemoizedValue { .. } = event().kind {
36 self.check_canceled();
37 }
38 }
34} 39}
35 40
36impl Default for RootDatabase { 41impl Default for RootDatabase {