aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/traits/chalk
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/chalk
parent1bf6b7360c3f1d0e20dece5227979bc4d74a352f (diff)
Use chalk_ir::OpaqueTyId
Diffstat (limited to 'crates/hir_ty/src/traits/chalk')
-rw-r--r--crates/hir_ty/src/traits/chalk/mapping.rs28
1 files changed, 6 insertions, 22 deletions
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