aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/traits
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2021-03-13 19:05:47 +0000
committerFlorian Diebold <[email protected]>2021-03-13 19:05:47 +0000
commitb035c314b4b0ecd2477fde216dbe7e8801f94d0d (patch)
treea2e152f5f16dd92f4c4be011be2399998dc7eb6f /crates/hir_ty/src/traits
parent1bf6b7360c3f1d0e20dece5227979bc4d74a352f (diff)
Use chalk_ir::OpaqueTyId
Diffstat (limited to 'crates/hir_ty/src/traits')
-rw-r--r--crates/hir_ty/src/traits/chalk.rs7
-rw-r--r--crates/hir_ty/src/traits/chalk/mapping.rs28
2 files changed, 9 insertions, 26 deletions
diff --git a/crates/hir_ty/src/traits/chalk.rs b/crates/hir_ty/src/traits/chalk.rs
index e7217bc11..1f3e1c07a 100644
--- a/crates/hir_ty/src/traits/chalk.rs
+++ b/crates/hir_ty/src/traits/chalk.rs
@@ -177,10 +177,9 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
177 } 177 }
178 178
179 fn opaque_ty_data(&self, id: chalk_ir::OpaqueTyId<Interner>) -> Arc<OpaqueTyDatum> { 179 fn opaque_ty_data(&self, id: chalk_ir::OpaqueTyId<Interner>) -> Arc<OpaqueTyDatum> {
180 let interned_id = crate::db::InternedOpaqueTyId::from(id); 180 let full_id = self.db.lookup_intern_impl_trait_id(id.into());
181 let full_id = self.db.lookup_intern_impl_trait_id(interned_id);
182 let bound = match full_id { 181 let bound = match full_id {
183 crate::OpaqueTyId::ReturnTypeImplTrait(func, idx) => { 182 crate::ImplTraitId::ReturnTypeImplTrait(func, idx) => {
184 let datas = self 183 let datas = self
185 .db 184 .db
186 .return_type_impl_traits(func) 185 .return_type_impl_traits(func)
@@ -202,7 +201,7 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
202 let num_vars = datas.num_binders; 201 let num_vars = datas.num_binders;
203 make_binders(bound, num_vars) 202 make_binders(bound, num_vars)
204 } 203 }
205 crate::OpaqueTyId::AsyncBlockTypeImplTrait(..) => { 204 crate::ImplTraitId::AsyncBlockTypeImplTrait(..) => {
206 if let Some((future_trait, future_output)) = self 205 if let Some((future_trait, future_output)) = self
207 .db 206 .db
208 .lang_item(self.krate, "future_trait".into()) 207 .lang_item(self.krate, "future_trait".into())
diff --git a/crates/hir_ty/src/traits/chalk/mapping.rs b/crates/hir_ty/src/traits/chalk/mapping.rs
index 460955756..2a66a2310 100644
--- a/crates/hir_ty/src/traits/chalk/mapping.rs
+++ b/crates/hir_ty/src/traits/chalk/mapping.rs
@@ -15,7 +15,7 @@ use crate::{
15 primitive::UintTy, 15 primitive::UintTy,
16 traits::{Canonical, Obligation}, 16 traits::{Canonical, Obligation},
17 AliasTy, CallableDefId, FnPointer, FnSig, GenericPredicate, InEnvironment, OpaqueTy, 17 AliasTy, CallableDefId, FnPointer, FnSig, GenericPredicate, InEnvironment, OpaqueTy,
18 OpaqueTyId, ProjectionPredicate, ProjectionTy, Scalar, Substs, TraitRef, Ty, 18 ProjectionPredicate, ProjectionTy, Scalar, Substs, TraitRef, Ty,
19}; 19};
20 20
21use super::interner::*; 21use super::interner::*;
@@ -41,8 +41,7 @@ impl ToChalk for Ty {
41 chalk_ir::TyKind::AssociatedType(assoc_type_id, substitution).intern(&Interner) 41 chalk_ir::TyKind::AssociatedType(assoc_type_id, substitution).intern(&Interner)
42 } 42 }
43 43
44 TyKind::OpaqueType(impl_trait_id, substs) => { 44 TyKind::OpaqueType(id, substs) => {
45 let id = impl_trait_id.to_chalk(db);
46 let substitution = substs.to_chalk(db); 45 let substitution = substs.to_chalk(db);
47 chalk_ir::TyKind::OpaqueType(id, substitution).intern(&Interner) 46 chalk_ir::TyKind::OpaqueType(id, substitution).intern(&Interner)
48 } 47 }
@@ -103,7 +102,7 @@ impl ToChalk for Ty {
103 chalk_ir::TyKind::Dyn(bounded_ty).intern(&Interner) 102 chalk_ir::TyKind::Dyn(bounded_ty).intern(&Interner)
104 } 103 }
105 TyKind::Alias(AliasTy::Opaque(opaque_ty)) => { 104 TyKind::Alias(AliasTy::Opaque(opaque_ty)) => {
106 let opaque_ty_id = opaque_ty.opaque_ty_id.to_chalk(db); 105 let opaque_ty_id = opaque_ty.opaque_ty_id;
107 let substitution = opaque_ty.parameters.to_chalk(db); 106 let substitution = opaque_ty.parameters.to_chalk(db);
108 chalk_ir::TyKind::Alias(chalk_ir::AliasTy::Opaque(chalk_ir::OpaqueTy { 107 chalk_ir::TyKind::Alias(chalk_ir::AliasTy::Opaque(chalk_ir::OpaqueTy {
109 opaque_ty_id, 108 opaque_ty_id,
@@ -125,9 +124,9 @@ impl ToChalk for Ty {
125 TyKind::Alias(AliasTy::Projection(ProjectionTy { associated_ty, parameters })) 124 TyKind::Alias(AliasTy::Projection(ProjectionTy { associated_ty, parameters }))
126 } 125 }
127 chalk_ir::TyKind::Alias(chalk_ir::AliasTy::Opaque(opaque_ty)) => { 126 chalk_ir::TyKind::Alias(chalk_ir::AliasTy::Opaque(opaque_ty)) => {
128 let impl_trait_id = from_chalk(db, opaque_ty.opaque_ty_id); 127 let opaque_ty_id = opaque_ty.opaque_ty_id;
129 let parameters = from_chalk(db, opaque_ty.substitution); 128 let parameters = from_chalk(db, opaque_ty.substitution);
130 TyKind::Alias(AliasTy::Opaque(OpaqueTy { opaque_ty_id: impl_trait_id, parameters })) 129 TyKind::Alias(AliasTy::Opaque(OpaqueTy { opaque_ty_id, parameters }))
131 } 130 }
132 chalk_ir::TyKind::Function(chalk_ir::FnPointer { 131 chalk_ir::TyKind::Function(chalk_ir::FnPointer {
133 num_binders, 132 num_binders,
@@ -165,7 +164,7 @@ impl ToChalk for Ty {
165 } 164 }
166 165
167 chalk_ir::TyKind::OpaqueType(opaque_type_id, subst) => { 166 chalk_ir::TyKind::OpaqueType(opaque_type_id, subst) => {
168 TyKind::OpaqueType(from_chalk(db, opaque_type_id), from_chalk(db, subst)) 167 TyKind::OpaqueType(opaque_type_id, from_chalk(db, subst))
169 } 168 }
170 169
171 chalk_ir::TyKind::Scalar(scalar) => TyKind::Scalar(scalar), 170 chalk_ir::TyKind::Scalar(scalar) => TyKind::Scalar(scalar),
@@ -268,21 +267,6 @@ impl ToChalk for hir_def::TraitId {
268 } 267 }
269} 268}
270 269
271impl ToChalk for OpaqueTyId {
272 type Chalk = chalk_ir::OpaqueTyId<Interner>;
273
274 fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::OpaqueTyId<Interner> {
275 db.intern_impl_trait_id(self).into()
276 }
277
278 fn from_chalk(
279 db: &dyn HirDatabase,
280 opaque_ty_id: chalk_ir::OpaqueTyId<Interner>,
281 ) -> OpaqueTyId {
282 db.lookup_intern_impl_trait_id(opaque_ty_id.into())
283 }
284}
285
286impl ToChalk for hir_def::ImplId { 270impl ToChalk for hir_def::ImplId {
287 type Chalk = ImplId; 271 type Chalk = ImplId;
288 272