diff options
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 | } |