aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_ty/src')
-rw-r--r--crates/ra_hir_ty/src/db.rs1
-rw-r--r--crates/ra_hir_ty/src/display.rs4
-rw-r--r--crates/ra_hir_ty/src/infer/expr.rs6
-rw-r--r--crates/ra_hir_ty/src/lib.rs2
-rw-r--r--crates/ra_hir_ty/src/lower.rs5
-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
8 files changed, 24 insertions, 31 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/display.rs b/crates/ra_hir_ty/src/display.rs
index 23cea1a2a..ac68c5661 100644
--- a/crates/ra_hir_ty/src/display.rs
+++ b/crates/ra_hir_ty/src/display.rs
@@ -369,7 +369,7 @@ impl HirDisplay for ApplicationTy {
369 let data = (*datas) 369 let data = (*datas)
370 .as_ref() 370 .as_ref()
371 .map(|rpit| rpit.impl_traits[idx as usize].bounds.clone()); 371 .map(|rpit| rpit.impl_traits[idx as usize].bounds.clone());
372 data.clone().subst(&self.parameters) 372 data.subst(&self.parameters)
373 } 373 }
374 }; 374 };
375 write!(f, "impl ")?; 375 write!(f, "impl ")?;
@@ -456,7 +456,7 @@ impl HirDisplay for Ty {
456 let data = (*datas) 456 let data = (*datas)
457 .as_ref() 457 .as_ref()
458 .map(|rpit| rpit.impl_traits[idx as usize].bounds.clone()); 458 .map(|rpit| rpit.impl_traits[idx as usize].bounds.clone());
459 data.clone().subst(&opaque_ty.parameters) 459 data.subst(&opaque_ty.parameters)
460 } 460 }
461 }; 461 };
462 write!(f, "impl ")?; 462 write!(f, "impl ")?;
diff --git a/crates/ra_hir_ty/src/infer/expr.rs b/crates/ra_hir_ty/src/infer/expr.rs
index 22884522a..06baac2a9 100644
--- a/crates/ra_hir_ty/src/infer/expr.rs
+++ b/crates/ra_hir_ty/src/infer/expr.rs
@@ -85,10 +85,8 @@ impl<'a> InferenceContext<'a> {
85 ctor: TypeCtor::Tuple { cardinality: num_args as u16 }, 85 ctor: TypeCtor::Tuple { cardinality: num_args as u16 },
86 parameters, 86 parameters,
87 }); 87 });
88 let substs = Substs::build_for_generics(&generic_params) 88 let substs =
89 .push(ty.clone()) 89 Substs::build_for_generics(&generic_params).push(ty.clone()).push(arg_ty).build();
90 .push(arg_ty.clone())
91 .build();
92 90
93 let trait_env = Arc::clone(&self.trait_env); 91 let trait_env = Arc::clone(&self.trait_env);
94 let implements_fn_trait = 92 let implements_fn_trait =
diff --git a/crates/ra_hir_ty/src/lib.rs b/crates/ra_hir_ty/src/lib.rs
index 7f3f5e771..c12bed4af 100644
--- a/crates/ra_hir_ty/src/lib.rs
+++ b/crates/ra_hir_ty/src/lib.rs
@@ -891,7 +891,7 @@ impl Ty {
891 let data = (*it) 891 let data = (*it)
892 .as_ref() 892 .as_ref()
893 .map(|rpit| rpit.impl_traits[idx as usize].bounds.clone()); 893 .map(|rpit| rpit.impl_traits[idx as usize].bounds.clone());
894 data.clone().subst(&opaque_ty.parameters) 894 data.subst(&opaque_ty.parameters)
895 }) 895 })
896 } 896 }
897 }; 897 };
diff --git a/crates/ra_hir_ty/src/lower.rs b/crates/ra_hir_ty/src/lower.rs
index 3dc154e92..3af8d55a1 100644
--- a/crates/ra_hir_ty/src/lower.rs
+++ b/crates/ra_hir_ty/src/lower.rs
@@ -720,8 +720,7 @@ fn assoc_type_bindings_from_type_bound<'a>(
720 None => return SmallVec::<[GenericPredicate; 1]>::new(), 720 None => return SmallVec::<[GenericPredicate; 1]>::new(),
721 Some(t) => t, 721 Some(t) => t,
722 }; 722 };
723 let projection_ty = 723 let projection_ty = ProjectionTy { associated_ty, parameters: super_trait_ref.substs };
724 ProjectionTy { associated_ty, parameters: super_trait_ref.substs.clone() };
725 let mut preds = SmallVec::with_capacity( 724 let mut preds = SmallVec::with_capacity(
726 binding.type_ref.as_ref().map_or(0, |_| 1) + binding.bounds.len(), 725 binding.type_ref.as_ref().map_or(0, |_| 1) + binding.bounds.len(),
727 ); 726 );
@@ -1216,7 +1215,7 @@ pub(crate) fn impl_trait_query(db: &dyn HirDatabase, impl_id: ImplId) -> Option<
1216} 1215}
1217 1216
1218pub(crate) fn return_type_impl_traits( 1217pub(crate) fn return_type_impl_traits(
1219 db: &impl HirDatabase, 1218 db: &dyn HirDatabase,
1220 def: hir_def::FunctionId, 1219 def: hir_def::FunctionId,
1221) -> Option<Arc<Binders<ReturnTypeImplTraits>>> { 1220) -> Option<Arc<Binders<ReturnTypeImplTraits>>> {
1222 // 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
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(