diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-07-07 09:15:40 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-07-07 09:15:40 +0100 |
commit | 7a8597bc20292f81bd8dce8b5ec09aababee4a7d (patch) | |
tree | 74488258fb566dc4344165ade6067d8f2ce7298f /crates/ra_hir_expand/src/test_db.rs | |
parent | d4bc2f25de6297c75f7b7f029df224b650ef3143 (diff) | |
parent | 4bbc385277bcab509c321b1374f72f1ef19d7750 (diff) |
Merge #5242
5242: Switch to fully dynamically dispatched salsa r=matklad a=matklad
This improves compile times quite a bit
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir_expand/src/test_db.rs')
-rw-r--r-- | crates/ra_hir_expand/src/test_db.rs | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/crates/ra_hir_expand/src/test_db.rs b/crates/ra_hir_expand/src/test_db.rs index 09fc18c36..332fa556f 100644 --- a/crates/ra_hir_expand/src/test_db.rs +++ b/crates/ra_hir_expand/src/test_db.rs | |||
@@ -1,7 +1,7 @@ | |||
1 | //! Database used for testing `hir_expand`. | 1 | //! Database used for testing `hir_expand`. |
2 | 2 | ||
3 | use std::{ | 3 | use std::{ |
4 | panic, | 4 | fmt, panic, |
5 | sync::{Arc, Mutex}, | 5 | sync::{Arc, Mutex}, |
6 | }; | 6 | }; |
7 | 7 | ||
@@ -13,25 +13,23 @@ use rustc_hash::FxHashSet; | |||
13 | ra_db::SourceDatabaseStorage, | 13 | ra_db::SourceDatabaseStorage, |
14 | crate::db::AstDatabaseStorage | 14 | crate::db::AstDatabaseStorage |
15 | )] | 15 | )] |
16 | #[derive(Debug, Default)] | 16 | #[derive(Default)] |
17 | pub struct TestDB { | 17 | pub struct TestDB { |
18 | runtime: salsa::Runtime<TestDB>, | 18 | storage: salsa::Storage<TestDB>, |
19 | events: Mutex<Option<Vec<salsa::Event<TestDB>>>>, | 19 | events: Mutex<Option<Vec<salsa::Event>>>, |
20 | } | 20 | } |
21 | 21 | ||
22 | impl salsa::Database for TestDB { | 22 | impl fmt::Debug for TestDB { |
23 | fn salsa_runtime(&self) -> &salsa::Runtime<Self> { | 23 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
24 | &self.runtime | 24 | f.debug_struct("TestDB").finish() |
25 | } | ||
26 | |||
27 | fn salsa_runtime_mut(&mut self) -> &mut salsa::Runtime<Self> { | ||
28 | &mut self.runtime | ||
29 | } | 25 | } |
26 | } | ||
30 | 27 | ||
31 | fn salsa_event(&self, event: impl Fn() -> salsa::Event<TestDB>) { | 28 | impl salsa::Database for TestDB { |
29 | fn salsa_event(&self, event: salsa::Event) { | ||
32 | let mut events = self.events.lock().unwrap(); | 30 | let mut events = self.events.lock().unwrap(); |
33 | if let Some(events) = &mut *events { | 31 | if let Some(events) = &mut *events { |
34 | events.push(event()); | 32 | events.push(event); |
35 | } | 33 | } |
36 | } | 34 | } |
37 | } | 35 | } |