aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty/src/traits
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2020-01-31 15:52:43 +0000
committerFlorian Diebold <[email protected]>2020-02-07 17:28:10 +0000
commited25cf70d5e0df9c7a33deb503ea14c2d97bd7a7 (patch)
treebc6e8620244d64beed8f1a9ce9059e5dfd2a0fbe /crates/ra_hir_ty/src/traits
parentf8b7b64bce772f21124b4790538ca97418cc23ca (diff)
Change Ty::Param to contain param ID
Diffstat (limited to 'crates/ra_hir_ty/src/traits')
-rw-r--r--crates/ra_hir_ty/src/traits/chalk.rs24
1 files changed, 12 insertions, 12 deletions
diff --git a/crates/ra_hir_ty/src/traits/chalk.rs b/crates/ra_hir_ty/src/traits/chalk.rs
index fe9cb556c..6e97f7dd2 100644
--- a/crates/ra_hir_ty/src/traits/chalk.rs
+++ b/crates/ra_hir_ty/src/traits/chalk.rs
@@ -142,8 +142,9 @@ impl ToChalk for Ty {
142 let substitution = proj_ty.parameters.to_chalk(db); 142 let substitution = proj_ty.parameters.to_chalk(db);
143 chalk_ir::AliasTy { associated_ty_id, substitution }.cast().intern() 143 chalk_ir::AliasTy { associated_ty_id, substitution }.cast().intern()
144 } 144 }
145 Ty::Param { idx, .. } => { 145 Ty::Param(id) => {
146 PlaceholderIndex { ui: UniverseIndex::ROOT, idx: idx as usize } 146 let interned_id = db.intern_type_param_id(id);
147 PlaceholderIndex { ui: UniverseIndex::ROOT, idx: interned_id.as_intern_id().as_usize() }
147 .to_ty::<TypeFamily>() 148 .to_ty::<TypeFamily>()
148 } 149 }
149 Ty::Bound(idx) => chalk_ir::TyData::BoundVar(idx as usize).intern(), 150 Ty::Bound(idx) => chalk_ir::TyData::BoundVar(idx as usize).intern(),
@@ -177,7 +178,8 @@ impl ToChalk for Ty {
177 }, 178 },
178 chalk_ir::TyData::Placeholder(idx) => { 179 chalk_ir::TyData::Placeholder(idx) => {
179 assert_eq!(idx.ui, UniverseIndex::ROOT); 180 assert_eq!(idx.ui, UniverseIndex::ROOT);
180 Ty::Param { idx: idx.idx as u32, name: crate::Name::missing() } 181 let interned_id = crate::db::GlobalTypeParamId::from_intern_id(crate::salsa::InternId::from(idx.idx));
182 Ty::Param(db.lookup_intern_type_param_id(interned_id))
181 } 183 }
182 chalk_ir::TyData::Alias(proj) => { 184 chalk_ir::TyData::Alias(proj) => {
183 let associated_ty = from_chalk(db, proj.associated_ty_id); 185 let associated_ty = from_chalk(db, proj.associated_ty_id);
@@ -524,7 +526,7 @@ fn convert_where_clauses(
524 // skip errored predicates completely 526 // skip errored predicates completely
525 continue; 527 continue;
526 } 528 }
527 result.push(pred.clone().subst(substs).to_chalk(db)); 529 result.push(pred.clone().subst_type_params(db, def, substs).to_chalk(db));
528 } 530 }
529 result 531 result
530} 532}
@@ -709,12 +711,12 @@ fn impl_block_datum(
709 let trait_ref = db 711 let trait_ref = db
710 .impl_trait(impl_id) 712 .impl_trait(impl_id)
711 // ImplIds for impls where the trait ref can't be resolved should never reach Chalk 713 // ImplIds for impls where the trait ref can't be resolved should never reach Chalk
712 .expect("invalid impl passed to Chalk"); 714 .expect("invalid impl passed to Chalk")
715 .value;
713 let impl_data = db.impl_data(impl_id); 716 let impl_data = db.impl_data(impl_id);
714 717
715 let generic_params = generics(db, impl_id.into()); 718 let generic_params = generics(db, impl_id.into());
716 let bound_vars = Substs::bound_vars(&generic_params); 719 let bound_vars = Substs::bound_vars(&generic_params);
717 let trait_ref = trait_ref.subst(&bound_vars);
718 let trait_ = trait_ref.trait_; 720 let trait_ = trait_ref.trait_;
719 let impl_type = if impl_id.lookup(db).container.module(db).krate == krate { 721 let impl_type = if impl_id.lookup(db).container.module(db).krate == krate {
720 chalk_rust_ir::ImplType::Local 722 chalk_rust_ir::ImplType::Local
@@ -789,20 +791,18 @@ fn type_alias_associated_ty_value(
789 _ => panic!("assoc ty value should be in impl"), 791 _ => panic!("assoc ty value should be in impl"),
790 }; 792 };
791 793
792 let trait_ref = db.impl_trait(impl_id).expect("assoc ty value should not exist"); // we don't return any assoc ty values if the impl'd trait can't be resolved 794 let trait_ref = db.impl_trait(impl_id).expect("assoc ty value should not exist").value; // we don't return any assoc ty values if the impl'd trait can't be resolved
793 795
794 let assoc_ty = db 796 let assoc_ty = db
795 .trait_data(trait_ref.trait_) 797 .trait_data(trait_ref.trait_)
796 .associated_type_by_name(&type_alias_data.name) 798 .associated_type_by_name(&type_alias_data.name)
797 .expect("assoc ty value should not exist"); // validated when building the impl data as well 799 .expect("assoc ty value should not exist"); // validated when building the impl data as well
798 let generic_params = generics(db, impl_id.into()); 800 let ty = db.ty(type_alias.into());
799 let bound_vars = Substs::bound_vars(&generic_params); 801 let value_bound = chalk_rust_ir::AssociatedTyValueBound { ty: ty.value.to_chalk(db) };
800 let ty = db.ty(type_alias.into()).subst(&bound_vars);
801 let value_bound = chalk_rust_ir::AssociatedTyValueBound { ty: ty.to_chalk(db) };
802 let value = chalk_rust_ir::AssociatedTyValue { 802 let value = chalk_rust_ir::AssociatedTyValue {
803 impl_id: Impl::ImplBlock(impl_id.into()).to_chalk(db), 803 impl_id: Impl::ImplBlock(impl_id.into()).to_chalk(db),
804 associated_ty_id: assoc_ty.to_chalk(db), 804 associated_ty_id: assoc_ty.to_chalk(db),
805 value: make_binders(value_bound, bound_vars.len()), 805 value: make_binders(value_bound, ty.num_binders),
806 }; 806 };
807 Arc::new(value) 807 Arc::new(value)
808} 808}