diff options
Diffstat (limited to 'crates/ra_hir_ty/src')
-rw-r--r-- | crates/ra_hir_ty/src/test_db.rs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/crates/ra_hir_ty/src/test_db.rs b/crates/ra_hir_ty/src/test_db.rs index 0e51f4130..874357008 100644 --- a/crates/ra_hir_ty/src/test_db.rs +++ b/crates/ra_hir_ty/src/test_db.rs | |||
@@ -1,10 +1,12 @@ | |||
1 | //! Database used for testing `hir`. | 1 | //! Database used for testing `hir`. |
2 | 2 | ||
3 | use std::{panic, sync::Arc}; | 3 | use std::{ |
4 | panic, | ||
5 | sync::{Arc, Mutex}, | ||
6 | }; | ||
4 | 7 | ||
5 | use hir_def::{db::DefDatabase, AssocItemId, ModuleDefId, ModuleId}; | 8 | use hir_def::{db::DefDatabase, AssocItemId, ModuleDefId, ModuleId}; |
6 | use hir_expand::diagnostics::DiagnosticSink; | 9 | use hir_expand::diagnostics::DiagnosticSink; |
7 | use parking_lot::Mutex; | ||
8 | use ra_db::{salsa, CrateId, FileId, FileLoader, FileLoaderDelegate, RelativePath, SourceDatabase}; | 10 | use ra_db::{salsa, CrateId, FileId, FileLoader, FileLoaderDelegate, RelativePath, SourceDatabase}; |
9 | 11 | ||
10 | use crate::{db::HirDatabase, expr::ExprValidator}; | 12 | use crate::{db::HirDatabase, expr::ExprValidator}; |
@@ -33,7 +35,7 @@ impl salsa::Database for TestDB { | |||
33 | } | 35 | } |
34 | 36 | ||
35 | fn salsa_event(&self, event: impl Fn() -> salsa::Event<TestDB>) { | 37 | fn salsa_event(&self, event: impl Fn() -> salsa::Event<TestDB>) { |
36 | let mut events = self.events.lock(); | 38 | let mut events = self.events.lock().unwrap(); |
37 | if let Some(events) = &mut *events { | 39 | if let Some(events) = &mut *events { |
38 | events.push(event()); | 40 | events.push(event()); |
39 | } | 41 | } |
@@ -122,9 +124,9 @@ impl TestDB { | |||
122 | 124 | ||
123 | impl TestDB { | 125 | impl TestDB { |
124 | pub fn log(&self, f: impl FnOnce()) -> Vec<salsa::Event<TestDB>> { | 126 | pub fn log(&self, f: impl FnOnce()) -> Vec<salsa::Event<TestDB>> { |
125 | *self.events.lock() = Some(Vec::new()); | 127 | *self.events.lock().unwrap() = Some(Vec::new()); |
126 | f(); | 128 | f(); |
127 | self.events.lock().take().unwrap() | 129 | self.events.lock().unwrap().take().unwrap() |
128 | } | 130 | } |
129 | 131 | ||
130 | pub fn log_executed(&self, f: impl FnOnce()) -> Vec<String> { | 132 | pub fn log_executed(&self, f: impl FnOnce()) -> Vec<String> { |