diff options
Diffstat (limited to 'crates/hir_ty/src/traits/chalk/mapping.rs')
-rw-r--r-- | crates/hir_ty/src/traits/chalk/mapping.rs | 212 |
1 files changed, 99 insertions, 113 deletions
diff --git a/crates/hir_ty/src/traits/chalk/mapping.rs b/crates/hir_ty/src/traits/chalk/mapping.rs index aef6b8a15..701359e6f 100644 --- a/crates/hir_ty/src/traits/chalk/mapping.rs +++ b/crates/hir_ty/src/traits/chalk/mapping.rs | |||
@@ -3,18 +3,16 @@ | |||
3 | //! Chalk (in both directions); plus some helper functions for more specialized | 3 | //! Chalk (in both directions); plus some helper functions for more specialized |
4 | //! conversions. | 4 | //! conversions. |
5 | 5 | ||
6 | use chalk_ir::{cast::Cast, fold::shift::Shift, interner::HasInterner, LifetimeData}; | 6 | use chalk_ir::{cast::Cast, interner::HasInterner}; |
7 | use chalk_solve::rust_ir; | 7 | use chalk_solve::rust_ir; |
8 | 8 | ||
9 | use base_db::salsa::InternKey; | 9 | use base_db::salsa::InternKey; |
10 | use hir_def::{GenericDefId, TypeAliasId}; | 10 | use hir_def::{GenericDefId, TypeAliasId}; |
11 | 11 | ||
12 | use crate::{ | 12 | use crate::{ |
13 | db::HirDatabase, | 13 | db::HirDatabase, static_lifetime, AliasTy, CallableDefId, Canonical, ConstrainedSubst, |
14 | primitive::UintTy, | 14 | DomainGoal, FnPointer, GenericArg, InEnvironment, OpaqueTy, ProjectionTy, ProjectionTyExt, |
15 | traits::{Canonical, DomainGoal}, | 15 | QuantifiedWhereClause, Substitution, TraitRef, Ty, TypeWalk, WhereClause, |
16 | AliasTy, CallableDefId, FnPointer, InEnvironment, OpaqueTy, ProjectionTy, | ||
17 | QuantifiedWhereClause, Scalar, Substitution, TraitRef, Ty, TypeWalk, WhereClause, | ||
18 | }; | 16 | }; |
19 | 17 | ||
20 | use super::interner::*; | 18 | use super::interner::*; |
@@ -24,16 +22,16 @@ impl ToChalk for Ty { | |||
24 | type Chalk = chalk_ir::Ty<Interner>; | 22 | type Chalk = chalk_ir::Ty<Interner>; |
25 | fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Ty<Interner> { | 23 | fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Ty<Interner> { |
26 | match self.into_inner() { | 24 | match self.into_inner() { |
27 | TyKind::Ref(m, ty) => ref_to_chalk(db, m, ty), | 25 | TyKind::Ref(m, lt, ty) => { |
28 | TyKind::Array(ty) => array_to_chalk(db, ty), | 26 | chalk_ir::TyKind::Ref(m, lt, ty.to_chalk(db)).intern(&Interner) |
29 | TyKind::Function(FnPointer { sig, substs, .. }) => { | 27 | } |
30 | let substitution = chalk_ir::FnSubst(substs.to_chalk(db).shifted_in(&Interner)); | 28 | TyKind::Array(ty, size) => { |
31 | chalk_ir::TyKind::Function(chalk_ir::FnPointer { | 29 | chalk_ir::TyKind::Array(ty.to_chalk(db), size).intern(&Interner) |
32 | num_binders: 0, | 30 | } |
33 | sig, | 31 | TyKind::Function(FnPointer { sig, substitution: substs, num_binders }) => { |
34 | substitution, | 32 | let substitution = chalk_ir::FnSubst(substs.0.to_chalk(db)); |
35 | }) | 33 | chalk_ir::TyKind::Function(chalk_ir::FnPointer { num_binders, sig, substitution }) |
36 | .intern(&Interner) | 34 | .intern(&Interner) |
37 | } | 35 | } |
38 | TyKind::AssociatedType(assoc_type_id, substs) => { | 36 | TyKind::AssociatedType(assoc_type_id, substs) => { |
39 | let substitution = substs.to_chalk(db); | 37 | let substitution = substs.to_chalk(db); |
@@ -45,7 +43,7 @@ impl ToChalk for Ty { | |||
45 | chalk_ir::TyKind::OpaqueType(id, substitution).intern(&Interner) | 43 | chalk_ir::TyKind::OpaqueType(id, substitution).intern(&Interner) |
46 | } | 44 | } |
47 | 45 | ||
48 | TyKind::ForeignType(id) => chalk_ir::TyKind::Foreign(id).intern(&Interner), | 46 | TyKind::Foreign(id) => chalk_ir::TyKind::Foreign(id).intern(&Interner), |
49 | 47 | ||
50 | TyKind::Scalar(scalar) => chalk_ir::TyKind::Scalar(scalar).intern(&Interner), | 48 | TyKind::Scalar(scalar) => chalk_ir::TyKind::Scalar(scalar).intern(&Interner), |
51 | 49 | ||
@@ -75,56 +73,41 @@ impl ToChalk for Ty { | |||
75 | chalk_ir::TyKind::Adt(adt_id, substitution).intern(&Interner) | 73 | chalk_ir::TyKind::Adt(adt_id, substitution).intern(&Interner) |
76 | } | 74 | } |
77 | TyKind::Alias(AliasTy::Projection(proj_ty)) => { | 75 | TyKind::Alias(AliasTy::Projection(proj_ty)) => { |
78 | let associated_ty_id = proj_ty.associated_ty_id; | 76 | chalk_ir::AliasTy::Projection(proj_ty.to_chalk(db)) |
79 | let substitution = proj_ty.substitution.to_chalk(db); | ||
80 | chalk_ir::AliasTy::Projection(chalk_ir::ProjectionTy { | ||
81 | associated_ty_id, | ||
82 | substitution, | ||
83 | }) | ||
84 | .cast(&Interner) | ||
85 | .intern(&Interner) | ||
86 | } | ||
87 | TyKind::Alias(AliasTy::Opaque(opaque_ty)) => { | ||
88 | let opaque_ty_id = opaque_ty.opaque_ty_id; | ||
89 | let substitution = opaque_ty.substitution.to_chalk(db); | ||
90 | chalk_ir::AliasTy::Opaque(chalk_ir::OpaqueTy { opaque_ty_id, substitution }) | ||
91 | .cast(&Interner) | 77 | .cast(&Interner) |
92 | .intern(&Interner) | 78 | .intern(&Interner) |
93 | } | 79 | } |
80 | TyKind::Alias(AliasTy::Opaque(opaque_ty)) => { | ||
81 | chalk_ir::AliasTy::Opaque(opaque_ty.to_chalk(db)).cast(&Interner).intern(&Interner) | ||
82 | } | ||
94 | TyKind::Placeholder(idx) => idx.to_ty::<Interner>(&Interner), | 83 | TyKind::Placeholder(idx) => idx.to_ty::<Interner>(&Interner), |
95 | TyKind::BoundVar(idx) => chalk_ir::TyKind::BoundVar(idx).intern(&Interner), | 84 | TyKind::BoundVar(idx) => chalk_ir::TyKind::BoundVar(idx).intern(&Interner), |
96 | TyKind::InferenceVar(..) => panic!("uncanonicalized infer ty"), | 85 | TyKind::InferenceVar(..) => panic!("uncanonicalized infer ty"), |
97 | TyKind::Dyn(dyn_ty) => { | 86 | TyKind::Dyn(dyn_ty) => { |
87 | let (bounds, binders) = dyn_ty.bounds.into_value_and_skipped_binders(); | ||
98 | let where_clauses = chalk_ir::QuantifiedWhereClauses::from_iter( | 88 | let where_clauses = chalk_ir::QuantifiedWhereClauses::from_iter( |
99 | &Interner, | 89 | &Interner, |
100 | dyn_ty.bounds.value.interned().iter().cloned().map(|p| p.to_chalk(db)), | 90 | bounds.interned().iter().cloned().map(|p| p.to_chalk(db)), |
101 | ); | 91 | ); |
102 | let bounded_ty = chalk_ir::DynTy { | 92 | let bounded_ty = chalk_ir::DynTy { |
103 | bounds: make_binders(where_clauses, 1), | 93 | bounds: chalk_ir::Binders::new(binders, where_clauses), |
104 | lifetime: LifetimeData::Static.intern(&Interner), | 94 | lifetime: dyn_ty.lifetime, |
105 | }; | 95 | }; |
106 | chalk_ir::TyKind::Dyn(bounded_ty).intern(&Interner) | 96 | chalk_ir::TyKind::Dyn(bounded_ty).intern(&Interner) |
107 | } | 97 | } |
108 | TyKind::Unknown => chalk_ir::TyKind::Error.intern(&Interner), | 98 | TyKind::Error => chalk_ir::TyKind::Error.intern(&Interner), |
109 | } | 99 | } |
110 | } | 100 | } |
111 | fn from_chalk(db: &dyn HirDatabase, chalk: chalk_ir::Ty<Interner>) -> Self { | 101 | fn from_chalk(db: &dyn HirDatabase, chalk: chalk_ir::Ty<Interner>) -> Self { |
112 | match chalk.data(&Interner).kind.clone() { | 102 | match chalk.data(&Interner).kind.clone() { |
113 | chalk_ir::TyKind::Error => TyKind::Unknown, | 103 | chalk_ir::TyKind::Error => TyKind::Error, |
114 | chalk_ir::TyKind::Array(ty, _size) => TyKind::Array(from_chalk(db, ty)), | 104 | chalk_ir::TyKind::Array(ty, size) => TyKind::Array(from_chalk(db, ty), size), |
115 | chalk_ir::TyKind::Placeholder(idx) => TyKind::Placeholder(idx), | 105 | chalk_ir::TyKind::Placeholder(idx) => TyKind::Placeholder(idx), |
116 | chalk_ir::TyKind::Alias(chalk_ir::AliasTy::Projection(proj)) => { | 106 | chalk_ir::TyKind::Alias(chalk_ir::AliasTy::Projection(proj)) => { |
117 | let associated_ty = proj.associated_ty_id; | 107 | TyKind::Alias(AliasTy::Projection(from_chalk(db, proj))) |
118 | let parameters = from_chalk(db, proj.substitution); | ||
119 | TyKind::Alias(AliasTy::Projection(ProjectionTy { | ||
120 | associated_ty_id: associated_ty, | ||
121 | substitution: parameters, | ||
122 | })) | ||
123 | } | 108 | } |
124 | chalk_ir::TyKind::Alias(chalk_ir::AliasTy::Opaque(opaque_ty)) => { | 109 | chalk_ir::TyKind::Alias(chalk_ir::AliasTy::Opaque(opaque_ty)) => { |
125 | let opaque_ty_id = opaque_ty.opaque_ty_id; | 110 | TyKind::Alias(AliasTy::Opaque(from_chalk(db, opaque_ty))) |
126 | let parameters = from_chalk(db, opaque_ty.substitution); | ||
127 | TyKind::Alias(AliasTy::Opaque(OpaqueTy { opaque_ty_id, substitution: parameters })) | ||
128 | } | 111 | } |
129 | chalk_ir::TyKind::Function(chalk_ir::FnPointer { | 112 | chalk_ir::TyKind::Function(chalk_ir::FnPointer { |
130 | num_binders, | 113 | num_binders, |
@@ -133,26 +116,25 @@ impl ToChalk for Ty { | |||
133 | .. | 116 | .. |
134 | }) => { | 117 | }) => { |
135 | assert_eq!(num_binders, 0); | 118 | assert_eq!(num_binders, 0); |
136 | let substs: Substitution = from_chalk( | 119 | let substs = crate::FnSubst(from_chalk(db, substitution.0)); |
137 | db, | 120 | TyKind::Function(FnPointer { num_binders, sig, substitution: substs }) |
138 | substitution.0.shifted_out(&Interner).expect("fn ptr should have no binders"), | ||
139 | ); | ||
140 | TyKind::Function(FnPointer { num_args: (substs.len() - 1), sig, substs }) | ||
141 | } | 121 | } |
142 | chalk_ir::TyKind::BoundVar(idx) => TyKind::BoundVar(idx), | 122 | chalk_ir::TyKind::BoundVar(idx) => TyKind::BoundVar(idx), |
143 | chalk_ir::TyKind::InferenceVar(_iv, _kind) => TyKind::Unknown, | 123 | chalk_ir::TyKind::InferenceVar(_iv, _kind) => TyKind::Error, |
144 | chalk_ir::TyKind::Dyn(where_clauses) => { | 124 | chalk_ir::TyKind::Dyn(dyn_ty) => { |
145 | assert_eq!(where_clauses.bounds.binders.len(&Interner), 1); | 125 | assert_eq!(dyn_ty.bounds.binders.len(&Interner), 1); |
146 | let bounds = where_clauses | 126 | let (bounds, binders) = dyn_ty.bounds.into_value_and_skipped_binders(); |
147 | .bounds | 127 | let where_clauses = crate::QuantifiedWhereClauses::from_iter( |
148 | .skip_binders() | 128 | &Interner, |
149 | .iter(&Interner) | 129 | bounds.interned().iter().cloned().map(|p| from_chalk(db, p)), |
150 | .map(|c| from_chalk(db, c.clone())); | 130 | ); |
151 | TyKind::Dyn(crate::DynTy { | 131 | TyKind::Dyn(crate::DynTy { |
152 | bounds: crate::Binders::new( | 132 | bounds: crate::Binders::new(binders, where_clauses), |
153 | 1, | 133 | // HACK: we sometimes get lifetime variables back in solutions |
154 | crate::QuantifiedWhereClauses::from_iter(&Interner, bounds), | 134 | // from Chalk, and don't have the infrastructure to substitute |
155 | ), | 135 | // them yet. So for now we just turn them into 'static right |
136 | // when we get them | ||
137 | lifetime: static_lifetime(), | ||
156 | }) | 138 | }) |
157 | } | 139 | } |
158 | 140 | ||
@@ -172,7 +154,11 @@ impl ToChalk for Ty { | |||
172 | chalk_ir::TyKind::Raw(mutability, ty) => TyKind::Raw(mutability, from_chalk(db, ty)), | 154 | chalk_ir::TyKind::Raw(mutability, ty) => TyKind::Raw(mutability, from_chalk(db, ty)), |
173 | chalk_ir::TyKind::Slice(ty) => TyKind::Slice(from_chalk(db, ty)), | 155 | chalk_ir::TyKind::Slice(ty) => TyKind::Slice(from_chalk(db, ty)), |
174 | chalk_ir::TyKind::Ref(mutability, _lifetime, ty) => { | 156 | chalk_ir::TyKind::Ref(mutability, _lifetime, ty) => { |
175 | TyKind::Ref(mutability, from_chalk(db, ty)) | 157 | // HACK: we sometimes get lifetime variables back in solutions |
158 | // from Chalk, and don't have the infrastructure to substitute | ||
159 | // them yet. So for now we just turn them into 'static right | ||
160 | // when we get them | ||
161 | TyKind::Ref(mutability, static_lifetime(), from_chalk(db, ty)) | ||
176 | } | 162 | } |
177 | chalk_ir::TyKind::Str => TyKind::Str, | 163 | chalk_ir::TyKind::Str => TyKind::Str, |
178 | chalk_ir::TyKind::Never => TyKind::Never, | 164 | chalk_ir::TyKind::Never => TyKind::Never, |
@@ -183,7 +169,7 @@ impl ToChalk for Ty { | |||
183 | 169 | ||
184 | chalk_ir::TyKind::Closure(id, subst) => TyKind::Closure(id, from_chalk(db, subst)), | 170 | chalk_ir::TyKind::Closure(id, subst) => TyKind::Closure(id, from_chalk(db, subst)), |
185 | 171 | ||
186 | chalk_ir::TyKind::Foreign(foreign_def_id) => TyKind::ForeignType(foreign_def_id), | 172 | chalk_ir::TyKind::Foreign(foreign_def_id) => TyKind::Foreign(foreign_def_id), |
187 | chalk_ir::TyKind::Generator(_, _) => unimplemented!(), // FIXME | 173 | chalk_ir::TyKind::Generator(_, _) => unimplemented!(), // FIXME |
188 | chalk_ir::TyKind::GeneratorWitness(_, _) => unimplemented!(), // FIXME | 174 | chalk_ir::TyKind::GeneratorWitness(_, _) => unimplemented!(), // FIXME |
189 | } | 175 | } |
@@ -191,50 +177,40 @@ impl ToChalk for Ty { | |||
191 | } | 177 | } |
192 | } | 178 | } |
193 | 179 | ||
194 | /// We currently don't model lifetimes, but Chalk does. So, we have to insert a | 180 | impl ToChalk for GenericArg { |
195 | /// fake lifetime here, because Chalks built-in logic may expect it to be there. | 181 | type Chalk = chalk_ir::GenericArg<Interner>; |
196 | fn ref_to_chalk( | 182 | |
197 | db: &dyn HirDatabase, | 183 | fn to_chalk(self, db: &dyn HirDatabase) -> Self::Chalk { |
198 | mutability: chalk_ir::Mutability, | 184 | match self.interned() { |
199 | ty: Ty, | 185 | crate::GenericArgData::Ty(ty) => ty.clone().to_chalk(db).cast(&Interner), |
200 | ) -> chalk_ir::Ty<Interner> { | 186 | } |
201 | let arg = ty.to_chalk(db); | 187 | } |
202 | let lifetime = LifetimeData::Static.intern(&Interner); | ||
203 | chalk_ir::TyKind::Ref(mutability, lifetime, arg).intern(&Interner) | ||
204 | } | ||
205 | 188 | ||
206 | /// We currently don't model constants, but Chalk does. So, we have to insert a | 189 | fn from_chalk(db: &dyn HirDatabase, chalk: Self::Chalk) -> Self { |
207 | /// fake constant here, because Chalks built-in logic may expect it to be there. | 190 | match chalk.interned() { |
208 | fn array_to_chalk(db: &dyn HirDatabase, ty: Ty) -> chalk_ir::Ty<Interner> { | 191 | chalk_ir::GenericArgData::Ty(ty) => Ty::from_chalk(db, ty.clone()).cast(&Interner), |
209 | let arg = ty.to_chalk(db); | 192 | chalk_ir::GenericArgData::Lifetime(_) => unimplemented!(), |
210 | let usize_ty = chalk_ir::TyKind::Scalar(Scalar::Uint(UintTy::Usize)).intern(&Interner); | 193 | chalk_ir::GenericArgData::Const(_) => unimplemented!(), |
211 | let const_ = chalk_ir::ConstData { | 194 | } |
212 | ty: usize_ty, | 195 | } |
213 | value: chalk_ir::ConstValue::Concrete(chalk_ir::ConcreteConst { interned: () }), | ||
214 | } | ||
215 | .intern(&Interner); | ||
216 | chalk_ir::TyKind::Array(arg, const_).intern(&Interner) | ||
217 | } | 196 | } |
218 | 197 | ||
219 | impl ToChalk for Substitution { | 198 | impl ToChalk for Substitution { |
220 | type Chalk = chalk_ir::Substitution<Interner>; | 199 | type Chalk = chalk_ir::Substitution<Interner>; |
221 | 200 | ||
222 | fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Substitution<Interner> { | 201 | fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Substitution<Interner> { |
223 | chalk_ir::Substitution::from_iter(&Interner, self.iter().map(|ty| ty.clone().to_chalk(db))) | 202 | chalk_ir::Substitution::from_iter( |
203 | &Interner, | ||
204 | self.iter(&Interner).map(|ty| ty.clone().to_chalk(db)), | ||
205 | ) | ||
224 | } | 206 | } |
225 | 207 | ||
226 | fn from_chalk( | 208 | fn from_chalk( |
227 | db: &dyn HirDatabase, | 209 | db: &dyn HirDatabase, |
228 | parameters: chalk_ir::Substitution<Interner>, | 210 | parameters: chalk_ir::Substitution<Interner>, |
229 | ) -> Substitution { | 211 | ) -> Substitution { |
230 | let tys = parameters | 212 | let tys = parameters.iter(&Interner).map(|p| from_chalk(db, p.clone())).collect(); |
231 | .iter(&Interner) | 213 | Substitution::intern(tys) |
232 | .map(|p| match p.ty(&Interner) { | ||
233 | Some(ty) => from_chalk(db, ty.clone()), | ||
234 | None => unimplemented!(), | ||
235 | }) | ||
236 | .collect(); | ||
237 | Substitution(tys) | ||
238 | } | 214 | } |
239 | } | 215 | } |
240 | 216 | ||
@@ -473,19 +449,25 @@ where | |||
473 | type Chalk = chalk_ir::Binders<T::Chalk>; | 449 | type Chalk = chalk_ir::Binders<T::Chalk>; |
474 | 450 | ||
475 | fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Binders<T::Chalk> { | 451 | fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Binders<T::Chalk> { |
476 | chalk_ir::Binders::new( | 452 | let (value, binders) = self.into_value_and_skipped_binders(); |
477 | chalk_ir::VariableKinds::from_iter( | 453 | chalk_ir::Binders::new(binders, value.to_chalk(db)) |
478 | &Interner, | ||
479 | std::iter::repeat(chalk_ir::VariableKind::Ty(chalk_ir::TyVariableKind::General)) | ||
480 | .take(self.num_binders), | ||
481 | ), | ||
482 | self.value.to_chalk(db), | ||
483 | ) | ||
484 | } | 454 | } |
485 | 455 | ||
486 | fn from_chalk(db: &dyn HirDatabase, binders: chalk_ir::Binders<T::Chalk>) -> crate::Binders<T> { | 456 | fn from_chalk(db: &dyn HirDatabase, binders: chalk_ir::Binders<T::Chalk>) -> crate::Binders<T> { |
487 | let (v, b) = binders.into_value_and_skipped_binders(); | 457 | let (v, b) = binders.into_value_and_skipped_binders(); |
488 | crate::Binders::new(b.len(&Interner), from_chalk(db, v)) | 458 | crate::Binders::new(b, from_chalk(db, v)) |
459 | } | ||
460 | } | ||
461 | |||
462 | impl ToChalk for crate::ConstrainedSubst { | ||
463 | type Chalk = chalk_ir::ConstrainedSubst<Interner>; | ||
464 | |||
465 | fn to_chalk(self, _db: &dyn HirDatabase) -> Self::Chalk { | ||
466 | unimplemented!() | ||
467 | } | ||
468 | |||
469 | fn from_chalk(db: &dyn HirDatabase, chalk: Self::Chalk) -> Self { | ||
470 | ConstrainedSubst { subst: from_chalk(db, chalk.subst) } | ||
489 | } | 471 | } |
490 | } | 472 | } |
491 | 473 | ||
@@ -511,7 +493,7 @@ pub(super) fn convert_where_clauses( | |||
511 | let generic_predicates = db.generic_predicates(def); | 493 | let generic_predicates = db.generic_predicates(def); |
512 | let mut result = Vec::with_capacity(generic_predicates.len()); | 494 | let mut result = Vec::with_capacity(generic_predicates.len()); |
513 | for pred in generic_predicates.iter() { | 495 | for pred in generic_predicates.iter() { |
514 | result.push(pred.clone().subst(substs).to_chalk(db)); | 496 | result.push(pred.clone().substitute(&Interner, substs).to_chalk(db)); |
515 | } | 497 | } |
516 | result | 498 | result |
517 | } | 499 | } |
@@ -523,27 +505,28 @@ pub(super) fn generic_predicate_to_inline_bound( | |||
523 | ) -> Option<chalk_ir::Binders<rust_ir::InlineBound<Interner>>> { | 505 | ) -> Option<chalk_ir::Binders<rust_ir::InlineBound<Interner>>> { |
524 | // An InlineBound is like a GenericPredicate, except the self type is left out. | 506 | // An InlineBound is like a GenericPredicate, except the self type is left out. |
525 | // We don't have a special type for this, but Chalk does. | 507 | // We don't have a special type for this, but Chalk does. |
526 | let self_ty_shifted_in = self_ty.clone().shift_bound_vars(DebruijnIndex::ONE); | 508 | let self_ty_shifted_in = self_ty.clone().shifted_in_from(DebruijnIndex::ONE); |
527 | match &pred.value { | 509 | let (pred, binders) = pred.as_ref().into_value_and_skipped_binders(); |
510 | match pred { | ||
528 | WhereClause::Implemented(trait_ref) => { | 511 | WhereClause::Implemented(trait_ref) => { |
529 | if trait_ref.self_type_parameter() != &self_ty_shifted_in { | 512 | if trait_ref.self_type_parameter(&Interner) != self_ty_shifted_in { |
530 | // we can only convert predicates back to type bounds if they | 513 | // we can only convert predicates back to type bounds if they |
531 | // have the expected self type | 514 | // have the expected self type |
532 | return None; | 515 | return None; |
533 | } | 516 | } |
534 | let args_no_self = trait_ref.substitution[1..] | 517 | let args_no_self = trait_ref.substitution.interned()[1..] |
535 | .iter() | 518 | .iter() |
536 | .map(|ty| ty.clone().to_chalk(db).cast(&Interner)) | 519 | .map(|ty| ty.clone().to_chalk(db).cast(&Interner)) |
537 | .collect(); | 520 | .collect(); |
538 | let trait_bound = rust_ir::TraitBound { trait_id: trait_ref.trait_id, args_no_self }; | 521 | let trait_bound = rust_ir::TraitBound { trait_id: trait_ref.trait_id, args_no_self }; |
539 | Some(make_binders(rust_ir::InlineBound::TraitBound(trait_bound), pred.num_binders)) | 522 | Some(chalk_ir::Binders::new(binders, rust_ir::InlineBound::TraitBound(trait_bound))) |
540 | } | 523 | } |
541 | WhereClause::AliasEq(AliasEq { alias: AliasTy::Projection(projection_ty), ty }) => { | 524 | WhereClause::AliasEq(AliasEq { alias: AliasTy::Projection(projection_ty), ty }) => { |
542 | if projection_ty.self_type_parameter() != &self_ty_shifted_in { | 525 | if projection_ty.self_type_parameter(&Interner) != self_ty_shifted_in { |
543 | return None; | 526 | return None; |
544 | } | 527 | } |
545 | let trait_ = projection_ty.trait_(db); | 528 | let trait_ = projection_ty.trait_(db); |
546 | let args_no_self = projection_ty.substitution[1..] | 529 | let args_no_self = projection_ty.substitution.interned()[1..] |
547 | .iter() | 530 | .iter() |
548 | .map(|ty| ty.clone().to_chalk(db).cast(&Interner)) | 531 | .map(|ty| ty.clone().to_chalk(db).cast(&Interner)) |
549 | .collect(); | 532 | .collect(); |
@@ -553,7 +536,10 @@ pub(super) fn generic_predicate_to_inline_bound( | |||
553 | associated_ty_id: projection_ty.associated_ty_id, | 536 | associated_ty_id: projection_ty.associated_ty_id, |
554 | parameters: Vec::new(), // FIXME we don't support generic associated types yet | 537 | parameters: Vec::new(), // FIXME we don't support generic associated types yet |
555 | }; | 538 | }; |
556 | Some(make_binders(rust_ir::InlineBound::AliasEqBound(alias_eq_bound), pred.num_binders)) | 539 | Some(chalk_ir::Binders::new( |
540 | binders, | ||
541 | rust_ir::InlineBound::AliasEqBound(alias_eq_bound), | ||
542 | )) | ||
557 | } | 543 | } |
558 | _ => None, | 544 | _ => None, |
559 | } | 545 | } |