diff options
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r-- | crates/ra_hir/src/db.rs | 17 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/traits.rs | 9 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/traits/chalk.rs | 32 |
3 files changed, 34 insertions, 24 deletions
diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs index d9fad0ae2..d75d71d66 100644 --- a/crates/ra_hir/src/db.rs +++ b/crates/ra_hir/src/db.rs | |||
@@ -125,31 +125,38 @@ pub trait HirDatabase: DefDatabase + AstDatabase { | |||
125 | fn intern_assoc_ty_value(&self, assoc_ty_value: AssocTyValue) -> ids::AssocTyValueId; | 125 | fn intern_assoc_ty_value(&self, assoc_ty_value: AssocTyValue) -> ids::AssocTyValueId; |
126 | 126 | ||
127 | #[salsa::invoke(crate::ty::traits::chalk::associated_ty_data_query)] | 127 | #[salsa::invoke(crate::ty::traits::chalk::associated_ty_data_query)] |
128 | fn associated_ty_data(&self, id: chalk_ir::TypeId) -> Arc<chalk_rust_ir::AssociatedTyDatum>; | 128 | fn associated_ty_data( |
129 | &self, | ||
130 | id: chalk_ir::TypeId, | ||
131 | ) -> Arc<chalk_rust_ir::AssociatedTyDatum<chalk_ir::family::ChalkIr>>; | ||
129 | 132 | ||
130 | #[salsa::invoke(crate::ty::traits::chalk::trait_datum_query)] | 133 | #[salsa::invoke(crate::ty::traits::chalk::trait_datum_query)] |
131 | fn trait_datum( | 134 | fn trait_datum( |
132 | &self, | 135 | &self, |
133 | krate: Crate, | 136 | krate: Crate, |
134 | trait_id: chalk_ir::TraitId, | 137 | trait_id: chalk_ir::TraitId, |
135 | ) -> Arc<chalk_rust_ir::TraitDatum>; | 138 | ) -> Arc<chalk_rust_ir::TraitDatum<chalk_ir::family::ChalkIr>>; |
136 | 139 | ||
137 | #[salsa::invoke(crate::ty::traits::chalk::struct_datum_query)] | 140 | #[salsa::invoke(crate::ty::traits::chalk::struct_datum_query)] |
138 | fn struct_datum( | 141 | fn struct_datum( |
139 | &self, | 142 | &self, |
140 | krate: Crate, | 143 | krate: Crate, |
141 | struct_id: chalk_ir::StructId, | 144 | struct_id: chalk_ir::StructId, |
142 | ) -> Arc<chalk_rust_ir::StructDatum>; | 145 | ) -> Arc<chalk_rust_ir::StructDatum<chalk_ir::family::ChalkIr>>; |
143 | 146 | ||
144 | #[salsa::invoke(crate::ty::traits::chalk::impl_datum_query)] | 147 | #[salsa::invoke(crate::ty::traits::chalk::impl_datum_query)] |
145 | fn impl_datum(&self, krate: Crate, impl_id: chalk_ir::ImplId) -> Arc<chalk_rust_ir::ImplDatum>; | 148 | fn impl_datum( |
149 | &self, | ||
150 | krate: Crate, | ||
151 | impl_id: chalk_ir::ImplId, | ||
152 | ) -> Arc<chalk_rust_ir::ImplDatum<chalk_ir::family::ChalkIr>>; | ||
146 | 153 | ||
147 | #[salsa::invoke(crate::ty::traits::chalk::associated_ty_value_query)] | 154 | #[salsa::invoke(crate::ty::traits::chalk::associated_ty_value_query)] |
148 | fn associated_ty_value( | 155 | fn associated_ty_value( |
149 | &self, | 156 | &self, |
150 | krate: Crate, | 157 | krate: Crate, |
151 | id: chalk_rust_ir::AssociatedTyValueId, | 158 | id: chalk_rust_ir::AssociatedTyValueId, |
152 | ) -> Arc<chalk_rust_ir::AssociatedTyValue>; | 159 | ) -> Arc<chalk_rust_ir::AssociatedTyValue<chalk_ir::family::ChalkIr>>; |
153 | 160 | ||
154 | #[salsa::invoke(crate::ty::traits::trait_solve_query)] | 161 | #[salsa::invoke(crate::ty::traits::trait_solve_query)] |
155 | fn trait_solve( | 162 | fn trait_solve( |
diff --git a/crates/ra_hir/src/ty/traits.rs b/crates/ra_hir/src/ty/traits.rs index 99dbab99e..45f725438 100644 --- a/crates/ra_hir/src/ty/traits.rs +++ b/crates/ra_hir/src/ty/traits.rs | |||
@@ -17,7 +17,7 @@ pub(crate) mod chalk; | |||
17 | #[derive(Debug, Clone)] | 17 | #[derive(Debug, Clone)] |
18 | pub struct TraitSolver { | 18 | pub struct TraitSolver { |
19 | krate: Crate, | 19 | krate: Crate, |
20 | inner: Arc<Mutex<chalk_solve::Solver>>, | 20 | inner: Arc<Mutex<chalk_solve::Solver<ChalkIr>>>, |
21 | } | 21 | } |
22 | 22 | ||
23 | /// We need eq for salsa | 23 | /// We need eq for salsa |
@@ -34,7 +34,7 @@ impl TraitSolver { | |||
34 | &self, | 34 | &self, |
35 | db: &impl HirDatabase, | 35 | db: &impl HirDatabase, |
36 | goal: &chalk_ir::UCanonical<chalk_ir::InEnvironment<chalk_ir::Goal<ChalkIr>>>, | 36 | goal: &chalk_ir::UCanonical<chalk_ir::InEnvironment<chalk_ir::Goal<ChalkIr>>>, |
37 | ) -> Option<chalk_solve::Solution> { | 37 | ) -> Option<chalk_solve::Solution<ChalkIr>> { |
38 | let context = ChalkContext { db, krate: self.krate }; | 38 | let context = ChalkContext { db, krate: self.krate }; |
39 | debug!("solve goal: {:?}", goal); | 39 | debug!("solve goal: {:?}", goal); |
40 | let mut solver = match self.inner.lock() { | 40 | let mut solver = match self.inner.lock() { |
@@ -196,7 +196,10 @@ pub(crate) fn trait_solve_query( | |||
196 | solution.map(|solution| solution_from_chalk(db, solution)) | 196 | solution.map(|solution| solution_from_chalk(db, solution)) |
197 | } | 197 | } |
198 | 198 | ||
199 | fn solution_from_chalk(db: &impl HirDatabase, solution: chalk_solve::Solution) -> Solution { | 199 | fn solution_from_chalk( |
200 | db: &impl HirDatabase, | ||
201 | solution: chalk_solve::Solution<ChalkIr>, | ||
202 | ) -> Solution { | ||
200 | let convert_subst = |subst: chalk_ir::Canonical<chalk_ir::Substitution<ChalkIr>>| { | 203 | let convert_subst = |subst: chalk_ir::Canonical<chalk_ir::Substitution<ChalkIr>>| { |
201 | let value = subst | 204 | let value = subst |
202 | .value | 205 | .value |
diff --git a/crates/ra_hir/src/ty/traits/chalk.rs b/crates/ra_hir/src/ty/traits/chalk.rs index 81a378bac..9bf93981a 100644 --- a/crates/ra_hir/src/ty/traits/chalk.rs +++ b/crates/ra_hir/src/ty/traits/chalk.rs | |||
@@ -418,20 +418,20 @@ fn convert_where_clauses( | |||
418 | result | 418 | result |
419 | } | 419 | } |
420 | 420 | ||
421 | impl<'a, DB> chalk_solve::RustIrDatabase for ChalkContext<'a, DB> | 421 | impl<'a, DB> chalk_solve::RustIrDatabase<ChalkIr> for ChalkContext<'a, DB> |
422 | where | 422 | where |
423 | DB: HirDatabase, | 423 | DB: HirDatabase, |
424 | { | 424 | { |
425 | fn associated_ty_data(&self, id: TypeId) -> Arc<AssociatedTyDatum> { | 425 | fn associated_ty_data(&self, id: TypeId) -> Arc<AssociatedTyDatum<ChalkIr>> { |
426 | self.db.associated_ty_data(id) | 426 | self.db.associated_ty_data(id) |
427 | } | 427 | } |
428 | fn trait_datum(&self, trait_id: chalk_ir::TraitId) -> Arc<TraitDatum> { | 428 | fn trait_datum(&self, trait_id: chalk_ir::TraitId) -> Arc<TraitDatum<ChalkIr>> { |
429 | self.db.trait_datum(self.krate, trait_id) | 429 | self.db.trait_datum(self.krate, trait_id) |
430 | } | 430 | } |
431 | fn struct_datum(&self, struct_id: chalk_ir::StructId) -> Arc<StructDatum> { | 431 | fn struct_datum(&self, struct_id: chalk_ir::StructId) -> Arc<StructDatum<ChalkIr>> { |
432 | self.db.struct_datum(self.krate, struct_id) | 432 | self.db.struct_datum(self.krate, struct_id) |
433 | } | 433 | } |
434 | fn impl_datum(&self, impl_id: ImplId) -> Arc<ImplDatum> { | 434 | fn impl_datum(&self, impl_id: ImplId) -> Arc<ImplDatum<ChalkIr>> { |
435 | self.db.impl_datum(self.krate, impl_id) | 435 | self.db.impl_datum(self.krate, impl_id) |
436 | } | 436 | } |
437 | fn impls_for_trait( | 437 | fn impls_for_trait( |
@@ -484,7 +484,7 @@ where | |||
484 | fn associated_ty_value( | 484 | fn associated_ty_value( |
485 | &self, | 485 | &self, |
486 | id: chalk_rust_ir::AssociatedTyValueId, | 486 | id: chalk_rust_ir::AssociatedTyValueId, |
487 | ) -> Arc<AssociatedTyValue> { | 487 | ) -> Arc<AssociatedTyValue<ChalkIr>> { |
488 | self.db.associated_ty_value(self.krate, id) | 488 | self.db.associated_ty_value(self.krate, id) |
489 | } | 489 | } |
490 | fn custom_clauses(&self) -> Vec<chalk_ir::ProgramClause<ChalkIr>> { | 490 | fn custom_clauses(&self) -> Vec<chalk_ir::ProgramClause<ChalkIr>> { |
@@ -502,7 +502,7 @@ where | |||
502 | pub(crate) fn associated_ty_data_query( | 502 | pub(crate) fn associated_ty_data_query( |
503 | db: &impl HirDatabase, | 503 | db: &impl HirDatabase, |
504 | id: TypeId, | 504 | id: TypeId, |
505 | ) -> Arc<AssociatedTyDatum> { | 505 | ) -> Arc<AssociatedTyDatum<ChalkIr>> { |
506 | debug!("associated_ty_data {:?}", id); | 506 | debug!("associated_ty_data {:?}", id); |
507 | let type_alias: TypeAlias = from_chalk(db, id); | 507 | let type_alias: TypeAlias = from_chalk(db, id); |
508 | let trait_ = match type_alias.container(db) { | 508 | let trait_ = match type_alias.container(db) { |
@@ -528,7 +528,7 @@ pub(crate) fn trait_datum_query( | |||
528 | db: &impl HirDatabase, | 528 | db: &impl HirDatabase, |
529 | krate: Crate, | 529 | krate: Crate, |
530 | trait_id: chalk_ir::TraitId, | 530 | trait_id: chalk_ir::TraitId, |
531 | ) -> Arc<TraitDatum> { | 531 | ) -> Arc<TraitDatum<ChalkIr>> { |
532 | debug!("trait_datum {:?}", trait_id); | 532 | debug!("trait_datum {:?}", trait_id); |
533 | if trait_id == UNKNOWN_TRAIT { | 533 | if trait_id == UNKNOWN_TRAIT { |
534 | let trait_datum_bound = chalk_rust_ir::TraitDatumBound { where_clauses: Vec::new() }; | 534 | let trait_datum_bound = chalk_rust_ir::TraitDatumBound { where_clauses: Vec::new() }; |
@@ -585,7 +585,7 @@ pub(crate) fn struct_datum_query( | |||
585 | db: &impl HirDatabase, | 585 | db: &impl HirDatabase, |
586 | krate: Crate, | 586 | krate: Crate, |
587 | struct_id: chalk_ir::StructId, | 587 | struct_id: chalk_ir::StructId, |
588 | ) -> Arc<StructDatum> { | 588 | ) -> Arc<StructDatum<ChalkIr>> { |
589 | debug!("struct_datum {:?}", struct_id); | 589 | debug!("struct_datum {:?}", struct_id); |
590 | let type_ctor: TypeCtor = from_chalk(db, struct_id); | 590 | let type_ctor: TypeCtor = from_chalk(db, struct_id); |
591 | debug!("struct {:?} = {:?}", struct_id, type_ctor); | 591 | debug!("struct {:?} = {:?}", struct_id, type_ctor); |
@@ -617,7 +617,7 @@ pub(crate) fn impl_datum_query( | |||
617 | db: &impl HirDatabase, | 617 | db: &impl HirDatabase, |
618 | krate: Crate, | 618 | krate: Crate, |
619 | impl_id: ImplId, | 619 | impl_id: ImplId, |
620 | ) -> Arc<ImplDatum> { | 620 | ) -> Arc<ImplDatum<ChalkIr>> { |
621 | let _p = ra_prof::profile("impl_datum"); | 621 | let _p = ra_prof::profile("impl_datum"); |
622 | debug!("impl_datum {:?}", impl_id); | 622 | debug!("impl_datum {:?}", impl_id); |
623 | let impl_: Impl = from_chalk(db, impl_id); | 623 | let impl_: Impl = from_chalk(db, impl_id); |
@@ -633,7 +633,7 @@ fn impl_block_datum( | |||
633 | krate: Crate, | 633 | krate: Crate, |
634 | impl_id: ImplId, | 634 | impl_id: ImplId, |
635 | impl_block: ImplBlock, | 635 | impl_block: ImplBlock, |
636 | ) -> Option<Arc<ImplDatum>> { | 636 | ) -> Option<Arc<ImplDatum<ChalkIr>>> { |
637 | let generic_params = impl_block.generic_params(db); | 637 | let generic_params = impl_block.generic_params(db); |
638 | let bound_vars = Substs::bound_vars(&generic_params); | 638 | let bound_vars = Substs::bound_vars(&generic_params); |
639 | let trait_ref = impl_block.target_trait_ref(db)?.subst(&bound_vars); | 639 | let trait_ref = impl_block.target_trait_ref(db)?.subst(&bound_vars); |
@@ -684,7 +684,7 @@ fn impl_block_datum( | |||
684 | Some(Arc::new(impl_datum)) | 684 | Some(Arc::new(impl_datum)) |
685 | } | 685 | } |
686 | 686 | ||
687 | fn invalid_impl_datum() -> Arc<ImplDatum> { | 687 | fn invalid_impl_datum() -> Arc<ImplDatum<ChalkIr>> { |
688 | let trait_ref = chalk_ir::TraitRef { | 688 | let trait_ref = chalk_ir::TraitRef { |
689 | trait_id: UNKNOWN_TRAIT, | 689 | trait_id: UNKNOWN_TRAIT, |
690 | parameters: vec![chalk_ir::TyData::BoundVar(0).cast().intern().cast()], | 690 | parameters: vec![chalk_ir::TyData::BoundVar(0).cast().intern().cast()], |
@@ -703,7 +703,7 @@ fn closure_fn_trait_impl_datum( | |||
703 | db: &impl HirDatabase, | 703 | db: &impl HirDatabase, |
704 | krate: Crate, | 704 | krate: Crate, |
705 | data: super::ClosureFnTraitImplData, | 705 | data: super::ClosureFnTraitImplData, |
706 | ) -> Option<Arc<ImplDatum>> { | 706 | ) -> Option<Arc<ImplDatum<ChalkIr>>> { |
707 | // for some closure |X, Y| -> Z: | 707 | // for some closure |X, Y| -> Z: |
708 | // impl<T, U, V> Fn<(T, U)> for closure<fn(T, U) -> V> { Output = V } | 708 | // impl<T, U, V> Fn<(T, U)> for closure<fn(T, U) -> V> { Output = V } |
709 | 709 | ||
@@ -760,7 +760,7 @@ pub(crate) fn associated_ty_value_query( | |||
760 | db: &impl HirDatabase, | 760 | db: &impl HirDatabase, |
761 | krate: Crate, | 761 | krate: Crate, |
762 | id: chalk_rust_ir::AssociatedTyValueId, | 762 | id: chalk_rust_ir::AssociatedTyValueId, |
763 | ) -> Arc<chalk_rust_ir::AssociatedTyValue> { | 763 | ) -> Arc<chalk_rust_ir::AssociatedTyValue<ChalkIr>> { |
764 | let data: AssocTyValue = from_chalk(db, id); | 764 | let data: AssocTyValue = from_chalk(db, id); |
765 | match data { | 765 | match data { |
766 | AssocTyValue::TypeAlias(type_alias) => { | 766 | AssocTyValue::TypeAlias(type_alias) => { |
@@ -776,7 +776,7 @@ fn type_alias_associated_ty_value( | |||
776 | db: &impl HirDatabase, | 776 | db: &impl HirDatabase, |
777 | _krate: Crate, | 777 | _krate: Crate, |
778 | type_alias: TypeAlias, | 778 | type_alias: TypeAlias, |
779 | ) -> Arc<AssociatedTyValue> { | 779 | ) -> Arc<AssociatedTyValue<ChalkIr>> { |
780 | let impl_block = type_alias.impl_block(db).expect("assoc ty value should be in impl"); | 780 | let impl_block = type_alias.impl_block(db).expect("assoc ty value should be in impl"); |
781 | let impl_id = Impl::ImplBlock(impl_block).to_chalk(db); | 781 | let impl_id = Impl::ImplBlock(impl_block).to_chalk(db); |
782 | let trait_ = impl_block | 782 | let trait_ = impl_block |
@@ -802,7 +802,7 @@ fn closure_fn_trait_output_assoc_ty_value( | |||
802 | db: &impl HirDatabase, | 802 | db: &impl HirDatabase, |
803 | krate: Crate, | 803 | krate: Crate, |
804 | data: super::ClosureFnTraitImplData, | 804 | data: super::ClosureFnTraitImplData, |
805 | ) -> Arc<AssociatedTyValue> { | 805 | ) -> Arc<AssociatedTyValue<ChalkIr>> { |
806 | let impl_id = Impl::ClosureFnTraitImpl(data.clone()).to_chalk(db); | 806 | let impl_id = Impl::ClosureFnTraitImpl(data.clone()).to_chalk(db); |
807 | 807 | ||
808 | let num_args: u16 = match &data.def.body(db)[data.expr] { | 808 | let num_args: u16 = match &data.def.body(db)[data.expr] { |