diff options
Diffstat (limited to 'crates/ra_hir/src/ty/traits')
-rw-r--r-- | crates/ra_hir/src/ty/traits/chalk.rs | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/crates/ra_hir/src/ty/traits/chalk.rs b/crates/ra_hir/src/ty/traits/chalk.rs index 0272dd9ae..06388a3ce 100644 --- a/crates/ra_hir/src/ty/traits/chalk.rs +++ b/crates/ra_hir/src/ty/traits/chalk.rs | |||
@@ -9,7 +9,7 @@ use chalk_ir::{ | |||
9 | }; | 9 | }; |
10 | use chalk_rust_ir::{AssociatedTyDatum, AssociatedTyValue, ImplDatum, StructDatum, TraitDatum}; | 10 | use chalk_rust_ir::{AssociatedTyDatum, AssociatedTyValue, ImplDatum, StructDatum, TraitDatum}; |
11 | 11 | ||
12 | use hir_def::{lang_item::LangItemTarget, GenericDefId}; | 12 | use hir_def::{lang_item::LangItemTarget, ContainerId, GenericDefId, Lookup, TypeAliasId}; |
13 | use hir_expand::name; | 13 | use hir_expand::name; |
14 | 14 | ||
15 | use ra_db::salsa::{InternId, InternKey}; | 15 | use ra_db::salsa::{InternId, InternKey}; |
@@ -203,15 +203,15 @@ impl ToChalk for Impl { | |||
203 | } | 203 | } |
204 | } | 204 | } |
205 | 205 | ||
206 | impl ToChalk for TypeAlias { | 206 | impl ToChalk for TypeAliasId { |
207 | type Chalk = chalk_ir::TypeId; | 207 | type Chalk = chalk_ir::TypeId; |
208 | 208 | ||
209 | fn to_chalk(self, _db: &impl HirDatabase) -> chalk_ir::TypeId { | 209 | fn to_chalk(self, _db: &impl HirDatabase) -> chalk_ir::TypeId { |
210 | chalk_ir::TypeId(id_to_chalk(self.id)) | 210 | chalk_ir::TypeId(id_to_chalk(self)) |
211 | } | 211 | } |
212 | 212 | ||
213 | fn from_chalk(_db: &impl HirDatabase, type_alias_id: chalk_ir::TypeId) -> TypeAlias { | 213 | fn from_chalk(_db: &impl HirDatabase, type_alias_id: chalk_ir::TypeId) -> TypeAliasId { |
214 | TypeAlias { id: id_from_chalk(type_alias_id.0) } | 214 | id_from_chalk(type_alias_id.0) |
215 | } | 215 | } |
216 | } | 216 | } |
217 | 217 | ||
@@ -504,21 +504,21 @@ pub(crate) fn associated_ty_data_query( | |||
504 | id: TypeId, | 504 | id: TypeId, |
505 | ) -> Arc<AssociatedTyDatum<ChalkIr>> { | 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: TypeAliasId = from_chalk(db, id); |
508 | let trait_ = match type_alias.container(db) { | 508 | let trait_ = match type_alias.lookup(db).container { |
509 | Some(crate::Container::Trait(t)) => t, | 509 | ContainerId::TraitId(t) => t, |
510 | _ => panic!("associated type not in trait"), | 510 | _ => panic!("associated type not in trait"), |
511 | }; | 511 | }; |
512 | let generic_params = db.generic_params(type_alias.id.into()); | 512 | let generic_params = db.generic_params(type_alias.into()); |
513 | let bound_data = chalk_rust_ir::AssociatedTyDatumBound { | 513 | let bound_data = chalk_rust_ir::AssociatedTyDatumBound { |
514 | // FIXME add bounds and where clauses | 514 | // FIXME add bounds and where clauses |
515 | bounds: vec![], | 515 | bounds: vec![], |
516 | where_clauses: vec![], | 516 | where_clauses: vec![], |
517 | }; | 517 | }; |
518 | let datum = AssociatedTyDatum { | 518 | let datum = AssociatedTyDatum { |
519 | trait_id: trait_.to_chalk(db), | 519 | trait_id: Trait::from(trait_).to_chalk(db), |
520 | id, | 520 | id, |
521 | name: lalrpop_intern::intern(&type_alias.name(db).to_string()), | 521 | name: lalrpop_intern::intern(&db.type_alias_data(type_alias).name.to_string()), |
522 | binders: make_binders(bound_data, generic_params.count_params_including_parent()), | 522 | binders: make_binders(bound_data, generic_params.count_params_including_parent()), |
523 | }; | 523 | }; |
524 | Arc::new(datum) | 524 | Arc::new(datum) |
@@ -566,7 +566,7 @@ pub(crate) fn trait_datum_query( | |||
566 | .items(db) | 566 | .items(db) |
567 | .into_iter() | 567 | .into_iter() |
568 | .filter_map(|trait_item| match trait_item { | 568 | .filter_map(|trait_item| match trait_item { |
569 | crate::AssocItem::TypeAlias(type_alias) => Some(type_alias), | 569 | crate::AssocItem::TypeAlias(type_alias) => Some(type_alias.id), |
570 | _ => None, | 570 | _ => None, |
571 | }) | 571 | }) |
572 | .map(|type_alias| type_alias.to_chalk(db)) | 572 | .map(|type_alias| type_alias.to_chalk(db)) |
@@ -785,7 +785,8 @@ fn type_alias_associated_ty_value( | |||
785 | .trait_; | 785 | .trait_; |
786 | let assoc_ty = trait_ | 786 | let assoc_ty = trait_ |
787 | .associated_type_by_name(db, &type_alias.name(db)) | 787 | .associated_type_by_name(db, &type_alias.name(db)) |
788 | .expect("assoc ty value should not exist"); // validated when building the impl data as well | 788 | .expect("assoc ty value should not exist") // validated when building the impl data as well |
789 | .id; | ||
789 | let generic_params = db.generic_params(impl_block.id.into()); | 790 | let generic_params = db.generic_params(impl_block.id.into()); |
790 | let bound_vars = Substs::bound_vars(&generic_params); | 791 | let bound_vars = Substs::bound_vars(&generic_params); |
791 | let ty = db.type_for_def(type_alias.into(), crate::ty::Namespace::Types).subst(&bound_vars); | 792 | let ty = db.type_for_def(type_alias.into(), crate::ty::Namespace::Types).subst(&bound_vars); |
@@ -820,7 +821,8 @@ fn closure_fn_trait_output_assoc_ty_value( | |||
820 | 821 | ||
821 | let output_ty_id = fn_once_trait | 822 | let output_ty_id = fn_once_trait |
822 | .associated_type_by_name(db, &name::OUTPUT_TYPE) | 823 | .associated_type_by_name(db, &name::OUTPUT_TYPE) |
823 | .expect("assoc ty value should not exist"); | 824 | .expect("assoc ty value should not exist") |
825 | .id; | ||
824 | 826 | ||
825 | let value_bound = chalk_rust_ir::AssociatedTyValueBound { ty: output_ty.to_chalk(db) }; | 827 | let value_bound = chalk_rust_ir::AssociatedTyValueBound { ty: output_ty.to_chalk(db) }; |
826 | 828 | ||