diff options
Diffstat (limited to 'crates/ra_hir_ty/src')
-rw-r--r-- | crates/ra_hir_ty/src/db.rs | 1 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/lower.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/test_db.rs | 31 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/tests.rs | 4 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/traits/chalk/tls.rs | 2 |
5 files changed, 18 insertions, 22 deletions
diff --git a/crates/ra_hir_ty/src/db.rs b/crates/ra_hir_ty/src/db.rs index dc06c0ee7..84afe0484 100644 --- a/crates/ra_hir_ty/src/db.rs +++ b/crates/ra_hir_ty/src/db.rs | |||
@@ -19,7 +19,6 @@ use crate::{ | |||
19 | use hir_expand::name::Name; | 19 | use hir_expand::name::Name; |
20 | 20 | ||
21 | #[salsa::query_group(HirDatabaseStorage)] | 21 | #[salsa::query_group(HirDatabaseStorage)] |
22 | #[salsa::requires(salsa::Database)] | ||
23 | pub trait HirDatabase: DefDatabase + Upcast<dyn DefDatabase> { | 22 | pub trait HirDatabase: DefDatabase + Upcast<dyn DefDatabase> { |
24 | #[salsa::invoke(infer_wait)] | 23 | #[salsa::invoke(infer_wait)] |
25 | #[salsa::transparent] | 24 | #[salsa::transparent] |
diff --git a/crates/ra_hir_ty/src/lower.rs b/crates/ra_hir_ty/src/lower.rs index 01af3187b..3af8d55a1 100644 --- a/crates/ra_hir_ty/src/lower.rs +++ b/crates/ra_hir_ty/src/lower.rs | |||
@@ -1215,7 +1215,7 @@ pub(crate) fn impl_trait_query(db: &dyn HirDatabase, impl_id: ImplId) -> Option< | |||
1215 | } | 1215 | } |
1216 | 1216 | ||
1217 | pub(crate) fn return_type_impl_traits( | 1217 | pub(crate) fn return_type_impl_traits( |
1218 | db: &impl HirDatabase, | 1218 | db: &dyn HirDatabase, |
1219 | def: hir_def::FunctionId, | 1219 | def: hir_def::FunctionId, |
1220 | ) -> Option<Arc<Binders<ReturnTypeImplTraits>>> { | 1220 | ) -> Option<Arc<Binders<ReturnTypeImplTraits>>> { |
1221 | // FIXME unify with fn_sig_for_fn instead of doing lowering twice, maybe | 1221 | // FIXME unify with fn_sig_for_fn instead of doing lowering twice, maybe |
diff --git a/crates/ra_hir_ty/src/test_db.rs b/crates/ra_hir_ty/src/test_db.rs index fddf0604d..dc447955f 100644 --- a/crates/ra_hir_ty/src/test_db.rs +++ b/crates/ra_hir_ty/src/test_db.rs | |||
@@ -1,7 +1,7 @@ | |||
1 | //! Database used for testing `hir`. | 1 | //! Database used for testing `hir`. |
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 | ||
@@ -26,10 +26,15 @@ use crate::{ | |||
26 | hir_def::db::DefDatabaseStorage, | 26 | hir_def::db::DefDatabaseStorage, |
27 | crate::db::HirDatabaseStorage | 27 | crate::db::HirDatabaseStorage |
28 | )] | 28 | )] |
29 | #[derive(Debug, Default)] | 29 | #[derive(Default)] |
30 | pub struct TestDB { | 30 | pub struct TestDB { |
31 | events: Mutex<Option<Vec<salsa::Event<TestDB>>>>, | 31 | storage: salsa::Storage<TestDB>, |
32 | runtime: salsa::Runtime<TestDB>, | 32 | events: Mutex<Option<Vec<salsa::Event>>>, |
33 | } | ||
34 | impl fmt::Debug for TestDB { | ||
35 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
36 | f.debug_struct("TestDB").finish() | ||
37 | } | ||
33 | } | 38 | } |
34 | 39 | ||
35 | impl Upcast<dyn AstDatabase> for TestDB { | 40 | impl Upcast<dyn AstDatabase> for TestDB { |
@@ -45,18 +50,10 @@ impl Upcast<dyn DefDatabase> for TestDB { | |||
45 | } | 50 | } |
46 | 51 | ||
47 | impl salsa::Database for TestDB { | 52 | impl salsa::Database for TestDB { |
48 | fn salsa_runtime(&self) -> &salsa::Runtime<TestDB> { | 53 | fn salsa_event(&self, event: salsa::Event) { |
49 | &self.runtime | ||
50 | } | ||
51 | |||
52 | fn salsa_runtime_mut(&mut self) -> &mut salsa::Runtime<Self> { | ||
53 | &mut self.runtime | ||
54 | } | ||
55 | |||
56 | fn salsa_event(&self, event: impl Fn() -> salsa::Event<TestDB>) { | ||
57 | let mut events = self.events.lock().unwrap(); | 54 | let mut events = self.events.lock().unwrap(); |
58 | if let Some(events) = &mut *events { | 55 | if let Some(events) = &mut *events { |
59 | events.push(event()); | 56 | events.push(event); |
60 | } | 57 | } |
61 | } | 58 | } |
62 | } | 59 | } |
@@ -64,8 +61,8 @@ impl salsa::Database for TestDB { | |||
64 | impl salsa::ParallelDatabase for TestDB { | 61 | impl salsa::ParallelDatabase for TestDB { |
65 | fn snapshot(&self) -> salsa::Snapshot<TestDB> { | 62 | fn snapshot(&self) -> salsa::Snapshot<TestDB> { |
66 | salsa::Snapshot::new(TestDB { | 63 | salsa::Snapshot::new(TestDB { |
64 | storage: self.storage.snapshot(), | ||
67 | events: Default::default(), | 65 | events: Default::default(), |
68 | runtime: self.runtime.snapshot(self), | ||
69 | }) | 66 | }) |
70 | } | 67 | } |
71 | } | 68 | } |
@@ -182,7 +179,7 @@ impl TestDB { | |||
182 | } | 179 | } |
183 | 180 | ||
184 | impl TestDB { | 181 | impl TestDB { |
185 | pub fn log(&self, f: impl FnOnce()) -> Vec<salsa::Event<TestDB>> { | 182 | pub fn log(&self, f: impl FnOnce()) -> Vec<salsa::Event> { |
186 | *self.events.lock().unwrap() = Some(Vec::new()); | 183 | *self.events.lock().unwrap() = Some(Vec::new()); |
187 | f(); | 184 | f(); |
188 | self.events.lock().unwrap().take().unwrap() | 185 | self.events.lock().unwrap().take().unwrap() |
@@ -196,7 +193,7 @@ impl TestDB { | |||
196 | // This pretty horrible, but `Debug` is the only way to inspect | 193 | // This pretty horrible, but `Debug` is the only way to inspect |
197 | // QueryDescriptor at the moment. | 194 | // QueryDescriptor at the moment. |
198 | salsa::EventKind::WillExecute { database_key } => { | 195 | salsa::EventKind::WillExecute { database_key } => { |
199 | Some(format!("{:?}", database_key)) | 196 | Some(format!("{:?}", database_key.debug(self))) |
200 | } | 197 | } |
201 | _ => None, | 198 | _ => None, |
202 | }) | 199 | }) |
diff --git a/crates/ra_hir_ty/src/tests.rs b/crates/ra_hir_ty/src/tests.rs index eeac34d14..69f2d7667 100644 --- a/crates/ra_hir_ty/src/tests.rs +++ b/crates/ra_hir_ty/src/tests.rs | |||
@@ -21,7 +21,7 @@ use hir_def::{ | |||
21 | }; | 21 | }; |
22 | use hir_expand::{db::AstDatabase, InFile}; | 22 | use hir_expand::{db::AstDatabase, InFile}; |
23 | use insta::assert_snapshot; | 23 | use insta::assert_snapshot; |
24 | use ra_db::{fixture::WithFixture, salsa::Database, FileRange, SourceDatabase}; | 24 | use ra_db::{fixture::WithFixture, FileRange, SourceDatabase, SourceDatabaseExt}; |
25 | use ra_syntax::{ | 25 | use ra_syntax::{ |
26 | algo, | 26 | algo, |
27 | ast::{self, AstNode}, | 27 | ast::{self, AstNode}, |
@@ -317,7 +317,7 @@ fn typing_whitespace_inside_a_function_should_not_invalidate_types() { | |||
317 | " | 317 | " |
318 | .to_string(); | 318 | .to_string(); |
319 | 319 | ||
320 | db.query_mut(ra_db::FileTextQuery).set(pos.file_id, Arc::new(new_text)); | 320 | db.set_file_text(pos.file_id, Arc::new(new_text)); |
321 | 321 | ||
322 | { | 322 | { |
323 | let events = db.log_executed(|| { | 323 | let events = db.log_executed(|| { |
diff --git a/crates/ra_hir_ty/src/traits/chalk/tls.rs b/crates/ra_hir_ty/src/traits/chalk/tls.rs index 556af7098..e6a9d3211 100644 --- a/crates/ra_hir_ty/src/traits/chalk/tls.rs +++ b/crates/ra_hir_ty/src/traits/chalk/tls.rs | |||
@@ -10,7 +10,7 @@ use hir_def::{AdtId, AssocContainerId, DefWithBodyId, Lookup, TypeAliasId}; | |||
10 | 10 | ||
11 | pub use unsafe_tls::{set_current_program, with_current_program}; | 11 | pub use unsafe_tls::{set_current_program, with_current_program}; |
12 | 12 | ||
13 | pub struct DebugContext<'a>(&'a (dyn HirDatabase + 'a)); | 13 | pub struct DebugContext<'a>(&'a dyn HirDatabase); |
14 | 14 | ||
15 | impl DebugContext<'_> { | 15 | impl DebugContext<'_> { |
16 | pub fn debug_struct_id( | 16 | pub fn debug_struct_id( |