aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_ty')
-rw-r--r--crates/ra_hir_ty/src/db.rs1
-rw-r--r--crates/ra_hir_ty/src/lower.rs2
-rw-r--r--crates/ra_hir_ty/src/test_db.rs31
-rw-r--r--crates/ra_hir_ty/src/tests.rs4
-rw-r--r--crates/ra_hir_ty/src/traits/chalk/tls.rs2
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::{
19use hir_expand::name::Name; 19use hir_expand::name::Name;
20 20
21#[salsa::query_group(HirDatabaseStorage)] 21#[salsa::query_group(HirDatabaseStorage)]
22#[salsa::requires(salsa::Database)]
23pub trait HirDatabase: DefDatabase + Upcast<dyn DefDatabase> { 22pub 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 3dc154e92..0fa0f7908 100644
--- a/crates/ra_hir_ty/src/lower.rs
+++ b/crates/ra_hir_ty/src/lower.rs
@@ -1216,7 +1216,7 @@ pub(crate) fn impl_trait_query(db: &dyn HirDatabase, impl_id: ImplId) -> Option<
1216} 1216}
1217 1217
1218pub(crate) fn return_type_impl_traits( 1218pub(crate) fn return_type_impl_traits(
1219 db: &impl HirDatabase, 1219 db: &dyn HirDatabase,
1220 def: hir_def::FunctionId, 1220 def: hir_def::FunctionId,
1221) -> Option<Arc<Binders<ReturnTypeImplTraits>>> { 1221) -> Option<Arc<Binders<ReturnTypeImplTraits>>> {
1222 // FIXME unify with fn_sig_for_fn instead of doing lowering twice, maybe 1222 // 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
3use std::{ 3use 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)]
30pub struct TestDB { 30pub 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}
34impl 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
35impl Upcast<dyn AstDatabase> for TestDB { 40impl Upcast<dyn AstDatabase> for TestDB {
@@ -45,18 +50,10 @@ impl Upcast<dyn DefDatabase> for TestDB {
45} 50}
46 51
47impl salsa::Database for TestDB { 52impl 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 {
64impl salsa::ParallelDatabase for TestDB { 61impl 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
184impl TestDB { 181impl 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};
22use hir_expand::{db::AstDatabase, InFile}; 22use hir_expand::{db::AstDatabase, InFile};
23use insta::assert_snapshot; 23use insta::assert_snapshot;
24use ra_db::{fixture::WithFixture, salsa::Database, FileRange, SourceDatabase}; 24use ra_db::{fixture::WithFixture, FileRange, SourceDatabase, SourceDatabaseExt};
25use ra_syntax::{ 25use 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
11pub use unsafe_tls::{set_current_program, with_current_program}; 11pub use unsafe_tls::{set_current_program, with_current_program};
12 12
13pub struct DebugContext<'a>(&'a (dyn HirDatabase + 'a)); 13pub struct DebugContext<'a>(&'a dyn HirDatabase);
14 14
15impl DebugContext<'_> { 15impl DebugContext<'_> {
16 pub fn debug_struct_id( 16 pub fn debug_struct_id(