aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_ty')
-rw-r--r--crates/hir_ty/src/traits.rs15
-rw-r--r--crates/hir_ty/src/traits/chalk/mapping.rs299
2 files changed, 42 insertions, 272 deletions
diff --git a/crates/hir_ty/src/traits.rs b/crates/hir_ty/src/traits.rs
index 7d87741b8..cc1d2ca18 100644
--- a/crates/hir_ty/src/traits.rs
+++ b/crates/hir_ty/src/traits.rs
@@ -173,20 +173,7 @@ fn solution_from_chalk(
173 db: &dyn HirDatabase, 173 db: &dyn HirDatabase,
174 solution: chalk_solve::Solution<Interner>, 174 solution: chalk_solve::Solution<Interner>,
175) -> Solution { 175) -> Solution {
176 match solution { 176 solution
177 chalk_solve::Solution::Unique(constr_subst) => {
178 Solution::Unique(from_chalk(db, constr_subst))
179 }
180 chalk_solve::Solution::Ambig(chalk_solve::Guidance::Definite(subst)) => {
181 Solution::Ambig(Guidance::Definite(from_chalk(db, subst)))
182 }
183 chalk_solve::Solution::Ambig(chalk_solve::Guidance::Suggested(subst)) => {
184 Solution::Ambig(Guidance::Suggested(from_chalk(db, subst)))
185 }
186 chalk_solve::Solution::Ambig(chalk_solve::Guidance::Unknown) => {
187 Solution::Ambig(Guidance::Unknown)
188 }
189 }
190} 177}
191 178
192#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] 179#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
diff --git a/crates/hir_ty/src/traits/chalk/mapping.rs b/crates/hir_ty/src/traits/chalk/mapping.rs
index 701359e6f..c2e289660 100644
--- a/crates/hir_ty/src/traits/chalk/mapping.rs
+++ b/crates/hir_ty/src/traits/chalk/mapping.rs
@@ -21,159 +21,10 @@ use super::*;
21impl ToChalk for Ty { 21impl ToChalk for Ty {
22 type Chalk = chalk_ir::Ty<Interner>; 22 type Chalk = chalk_ir::Ty<Interner>;
23 fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Ty<Interner> { 23 fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Ty<Interner> {
24 match self.into_inner() { 24 self
25 TyKind::Ref(m, lt, ty) => {
26 chalk_ir::TyKind::Ref(m, lt, ty.to_chalk(db)).intern(&Interner)
27 }
28 TyKind::Array(ty, size) => {
29 chalk_ir::TyKind::Array(ty.to_chalk(db), size).intern(&Interner)
30 }
31 TyKind::Function(FnPointer { sig, substitution: substs, num_binders }) => {
32 let substitution = chalk_ir::FnSubst(substs.0.to_chalk(db));
33 chalk_ir::TyKind::Function(chalk_ir::FnPointer { num_binders, sig, substitution })
34 .intern(&Interner)
35 }
36 TyKind::AssociatedType(assoc_type_id, substs) => {
37 let substitution = substs.to_chalk(db);
38 chalk_ir::TyKind::AssociatedType(assoc_type_id, substitution).intern(&Interner)
39 }
40
41 TyKind::OpaqueType(id, substs) => {
42 let substitution = substs.to_chalk(db);
43 chalk_ir::TyKind::OpaqueType(id, substitution).intern(&Interner)
44 }
45
46 TyKind::Foreign(id) => chalk_ir::TyKind::Foreign(id).intern(&Interner),
47
48 TyKind::Scalar(scalar) => chalk_ir::TyKind::Scalar(scalar).intern(&Interner),
49
50 TyKind::Tuple(cardinality, substs) => {
51 let substitution = substs.to_chalk(db);
52 chalk_ir::TyKind::Tuple(cardinality, substitution).intern(&Interner)
53 }
54 TyKind::Raw(mutability, ty) => {
55 let ty = ty.to_chalk(db);
56 chalk_ir::TyKind::Raw(mutability, ty).intern(&Interner)
57 }
58 TyKind::Slice(ty) => chalk_ir::TyKind::Slice(ty.to_chalk(db)).intern(&Interner),
59 TyKind::Str => chalk_ir::TyKind::Str.intern(&Interner),
60 TyKind::FnDef(id, substs) => {
61 let substitution = substs.to_chalk(db);
62 chalk_ir::TyKind::FnDef(id, substitution).intern(&Interner)
63 }
64 TyKind::Never => chalk_ir::TyKind::Never.intern(&Interner),
65
66 TyKind::Closure(closure_id, substs) => {
67 let substitution = substs.to_chalk(db);
68 chalk_ir::TyKind::Closure(closure_id, substitution).intern(&Interner)
69 }
70
71 TyKind::Adt(adt_id, substs) => {
72 let substitution = substs.to_chalk(db);
73 chalk_ir::TyKind::Adt(adt_id, substitution).intern(&Interner)
74 }
75 TyKind::Alias(AliasTy::Projection(proj_ty)) => {
76 chalk_ir::AliasTy::Projection(proj_ty.to_chalk(db))
77 .cast(&Interner)
78 .intern(&Interner)
79 }
80 TyKind::Alias(AliasTy::Opaque(opaque_ty)) => {
81 chalk_ir::AliasTy::Opaque(opaque_ty.to_chalk(db)).cast(&Interner).intern(&Interner)
82 }
83 TyKind::Placeholder(idx) => idx.to_ty::<Interner>(&Interner),
84 TyKind::BoundVar(idx) => chalk_ir::TyKind::BoundVar(idx).intern(&Interner),
85 TyKind::InferenceVar(..) => panic!("uncanonicalized infer ty"),
86 TyKind::Dyn(dyn_ty) => {
87 let (bounds, binders) = dyn_ty.bounds.into_value_and_skipped_binders();
88 let where_clauses = chalk_ir::QuantifiedWhereClauses::from_iter(
89 &Interner,
90 bounds.interned().iter().cloned().map(|p| p.to_chalk(db)),
91 );
92 let bounded_ty = chalk_ir::DynTy {
93 bounds: chalk_ir::Binders::new(binders, where_clauses),
94 lifetime: dyn_ty.lifetime,
95 };
96 chalk_ir::TyKind::Dyn(bounded_ty).intern(&Interner)
97 }
98 TyKind::Error => chalk_ir::TyKind::Error.intern(&Interner),
99 }
100 } 25 }
101 fn from_chalk(db: &dyn HirDatabase, chalk: chalk_ir::Ty<Interner>) -> Self { 26 fn from_chalk(db: &dyn HirDatabase, chalk: chalk_ir::Ty<Interner>) -> Self {
102 match chalk.data(&Interner).kind.clone() { 27 chalk
103 chalk_ir::TyKind::Error => TyKind::Error,
104 chalk_ir::TyKind::Array(ty, size) => TyKind::Array(from_chalk(db, ty), size),
105 chalk_ir::TyKind::Placeholder(idx) => TyKind::Placeholder(idx),
106 chalk_ir::TyKind::Alias(chalk_ir::AliasTy::Projection(proj)) => {
107 TyKind::Alias(AliasTy::Projection(from_chalk(db, proj)))
108 }
109 chalk_ir::TyKind::Alias(chalk_ir::AliasTy::Opaque(opaque_ty)) => {
110 TyKind::Alias(AliasTy::Opaque(from_chalk(db, opaque_ty)))
111 }
112 chalk_ir::TyKind::Function(chalk_ir::FnPointer {
113 num_binders,
114 sig,
115 substitution,
116 ..
117 }) => {
118 assert_eq!(num_binders, 0);
119 let substs = crate::FnSubst(from_chalk(db, substitution.0));
120 TyKind::Function(FnPointer { num_binders, sig, substitution: substs })
121 }
122 chalk_ir::TyKind::BoundVar(idx) => TyKind::BoundVar(idx),
123 chalk_ir::TyKind::InferenceVar(_iv, _kind) => TyKind::Error,
124 chalk_ir::TyKind::Dyn(dyn_ty) => {
125 assert_eq!(dyn_ty.bounds.binders.len(&Interner), 1);
126 let (bounds, binders) = dyn_ty.bounds.into_value_and_skipped_binders();
127 let where_clauses = crate::QuantifiedWhereClauses::from_iter(
128 &Interner,
129 bounds.interned().iter().cloned().map(|p| from_chalk(db, p)),
130 );
131 TyKind::Dyn(crate::DynTy {
132 bounds: crate::Binders::new(binders, where_clauses),
133 // HACK: we sometimes get lifetime variables back in solutions
134 // from Chalk, and don't have the infrastructure to substitute
135 // them yet. So for now we just turn them into 'static right
136 // when we get them
137 lifetime: static_lifetime(),
138 })
139 }
140
141 chalk_ir::TyKind::Adt(adt_id, subst) => TyKind::Adt(adt_id, from_chalk(db, subst)),
142 chalk_ir::TyKind::AssociatedType(type_id, subst) => {
143 TyKind::AssociatedType(type_id, from_chalk(db, subst))
144 }
145
146 chalk_ir::TyKind::OpaqueType(opaque_type_id, subst) => {
147 TyKind::OpaqueType(opaque_type_id, from_chalk(db, subst))
148 }
149
150 chalk_ir::TyKind::Scalar(scalar) => TyKind::Scalar(scalar),
151 chalk_ir::TyKind::Tuple(cardinality, subst) => {
152 TyKind::Tuple(cardinality, from_chalk(db, subst))
153 }
154 chalk_ir::TyKind::Raw(mutability, ty) => TyKind::Raw(mutability, from_chalk(db, ty)),
155 chalk_ir::TyKind::Slice(ty) => TyKind::Slice(from_chalk(db, ty)),
156 chalk_ir::TyKind::Ref(mutability, _lifetime, 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))
162 }
163 chalk_ir::TyKind::Str => TyKind::Str,
164 chalk_ir::TyKind::Never => TyKind::Never,
165
166 chalk_ir::TyKind::FnDef(fn_def_id, subst) => {
167 TyKind::FnDef(fn_def_id, from_chalk(db, subst))
168 }
169
170 chalk_ir::TyKind::Closure(id, subst) => TyKind::Closure(id, from_chalk(db, subst)),
171
172 chalk_ir::TyKind::Foreign(foreign_def_id) => TyKind::Foreign(foreign_def_id),
173 chalk_ir::TyKind::Generator(_, _) => unimplemented!(), // FIXME
174 chalk_ir::TyKind::GeneratorWitness(_, _) => unimplemented!(), // FIXME
175 }
176 .intern(&Interner)
177 } 28 }
178} 29}
179 30
@@ -181,17 +32,11 @@ impl ToChalk for GenericArg {
181 type Chalk = chalk_ir::GenericArg<Interner>; 32 type Chalk = chalk_ir::GenericArg<Interner>;
182 33
183 fn to_chalk(self, db: &dyn HirDatabase) -> Self::Chalk { 34 fn to_chalk(self, db: &dyn HirDatabase) -> Self::Chalk {
184 match self.interned() { 35 self
185 crate::GenericArgData::Ty(ty) => ty.clone().to_chalk(db).cast(&Interner),
186 }
187 } 36 }
188 37
189 fn from_chalk(db: &dyn HirDatabase, chalk: Self::Chalk) -> Self { 38 fn from_chalk(db: &dyn HirDatabase, chalk: Self::Chalk) -> Self {
190 match chalk.interned() { 39 chalk
191 chalk_ir::GenericArgData::Ty(ty) => Ty::from_chalk(db, ty.clone()).cast(&Interner),
192 chalk_ir::GenericArgData::Lifetime(_) => unimplemented!(),
193 chalk_ir::GenericArgData::Const(_) => unimplemented!(),
194 }
195 } 40 }
196} 41}
197 42
@@ -199,18 +44,14 @@ impl ToChalk for Substitution {
199 type Chalk = chalk_ir::Substitution<Interner>; 44 type Chalk = chalk_ir::Substitution<Interner>;
200 45
201 fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Substitution<Interner> { 46 fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Substitution<Interner> {
202 chalk_ir::Substitution::from_iter( 47 self
203 &Interner,
204 self.iter(&Interner).map(|ty| ty.clone().to_chalk(db)),
205 )
206 } 48 }
207 49
208 fn from_chalk( 50 fn from_chalk(
209 db: &dyn HirDatabase, 51 db: &dyn HirDatabase,
210 parameters: chalk_ir::Substitution<Interner>, 52 parameters: chalk_ir::Substitution<Interner>,
211 ) -> Substitution { 53 ) -> Substitution {
212 let tys = parameters.iter(&Interner).map(|p| from_chalk(db, p.clone())).collect(); 54 parameters
213 Substitution::intern(tys)
214 } 55 }
215} 56}
216 57
@@ -218,15 +59,11 @@ impl ToChalk for TraitRef {
218 type Chalk = chalk_ir::TraitRef<Interner>; 59 type Chalk = chalk_ir::TraitRef<Interner>;
219 60
220 fn to_chalk(self: TraitRef, db: &dyn HirDatabase) -> chalk_ir::TraitRef<Interner> { 61 fn to_chalk(self: TraitRef, db: &dyn HirDatabase) -> chalk_ir::TraitRef<Interner> {
221 let trait_id = self.trait_id; 62 self
222 let substitution = self.substitution.to_chalk(db);
223 chalk_ir::TraitRef { trait_id, substitution }
224 } 63 }
225 64
226 fn from_chalk(db: &dyn HirDatabase, trait_ref: chalk_ir::TraitRef<Interner>) -> Self { 65 fn from_chalk(db: &dyn HirDatabase, trait_ref: chalk_ir::TraitRef<Interner>) -> Self {
227 let trait_id = trait_ref.trait_id; 66 trait_ref
228 let substs = from_chalk(db, trait_ref.substitution);
229 TraitRef { trait_id, substitution: substs }
230 } 67 }
231} 68}
232 69
@@ -287,34 +124,14 @@ impl ToChalk for WhereClause {
287 type Chalk = chalk_ir::WhereClause<Interner>; 124 type Chalk = chalk_ir::WhereClause<Interner>;
288 125
289 fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::WhereClause<Interner> { 126 fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::WhereClause<Interner> {
290 match self { 127 self
291 WhereClause::Implemented(trait_ref) => {
292 chalk_ir::WhereClause::Implemented(trait_ref.to_chalk(db))
293 }
294 WhereClause::AliasEq(alias_eq) => chalk_ir::WhereClause::AliasEq(alias_eq.to_chalk(db)),
295 }
296 } 128 }
297 129
298 fn from_chalk( 130 fn from_chalk(
299 db: &dyn HirDatabase, 131 db: &dyn HirDatabase,
300 where_clause: chalk_ir::WhereClause<Interner>, 132 where_clause: chalk_ir::WhereClause<Interner>,
301 ) -> WhereClause { 133 ) -> WhereClause {
302 match where_clause { 134 where_clause
303 chalk_ir::WhereClause::Implemented(tr) => WhereClause::Implemented(from_chalk(db, tr)),
304 chalk_ir::WhereClause::AliasEq(alias_eq) => {
305 WhereClause::AliasEq(from_chalk(db, alias_eq))
306 }
307
308 chalk_ir::WhereClause::LifetimeOutlives(_) => {
309 // we shouldn't get these from Chalk
310 panic!("encountered LifetimeOutlives from Chalk")
311 }
312
313 chalk_ir::WhereClause::TypeOutlives(_) => {
314 // we shouldn't get these from Chalk
315 panic!("encountered TypeOutlives from Chalk")
316 }
317 }
318 } 135 }
319} 136}
320 137
@@ -322,37 +139,25 @@ impl ToChalk for ProjectionTy {
322 type Chalk = chalk_ir::ProjectionTy<Interner>; 139 type Chalk = chalk_ir::ProjectionTy<Interner>;
323 140
324 fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::ProjectionTy<Interner> { 141 fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::ProjectionTy<Interner> {
325 chalk_ir::ProjectionTy { 142 self
326 associated_ty_id: self.associated_ty_id,
327 substitution: self.substitution.to_chalk(db),
328 }
329 } 143 }
330 144
331 fn from_chalk( 145 fn from_chalk(
332 db: &dyn HirDatabase, 146 db: &dyn HirDatabase,
333 projection_ty: chalk_ir::ProjectionTy<Interner>, 147 projection_ty: chalk_ir::ProjectionTy<Interner>,
334 ) -> ProjectionTy { 148 ) -> ProjectionTy {
335 ProjectionTy { 149 projection_ty
336 associated_ty_id: projection_ty.associated_ty_id,
337 substitution: from_chalk(db, projection_ty.substitution),
338 }
339 } 150 }
340} 151}
341impl ToChalk for OpaqueTy { 152impl ToChalk for OpaqueTy {
342 type Chalk = chalk_ir::OpaqueTy<Interner>; 153 type Chalk = chalk_ir::OpaqueTy<Interner>;
343 154
344 fn to_chalk(self, db: &dyn HirDatabase) -> Self::Chalk { 155 fn to_chalk(self, db: &dyn HirDatabase) -> Self::Chalk {
345 chalk_ir::OpaqueTy { 156 self
346 opaque_ty_id: self.opaque_ty_id,
347 substitution: self.substitution.to_chalk(db),
348 }
349 } 157 }
350 158
351 fn from_chalk(db: &dyn HirDatabase, chalk: Self::Chalk) -> Self { 159 fn from_chalk(db: &dyn HirDatabase, chalk: Self::Chalk) -> Self {
352 OpaqueTy { 160 chalk
353 opaque_ty_id: chalk.opaque_ty_id,
354 substitution: from_chalk(db, chalk.substitution),
355 }
356 } 161 }
357} 162}
358 163
@@ -360,21 +165,11 @@ impl ToChalk for AliasTy {
360 type Chalk = chalk_ir::AliasTy<Interner>; 165 type Chalk = chalk_ir::AliasTy<Interner>;
361 166
362 fn to_chalk(self, db: &dyn HirDatabase) -> Self::Chalk { 167 fn to_chalk(self, db: &dyn HirDatabase) -> Self::Chalk {
363 match self { 168 self
364 AliasTy::Projection(projection_ty) => {
365 chalk_ir::AliasTy::Projection(projection_ty.to_chalk(db))
366 }
367 AliasTy::Opaque(opaque_ty) => chalk_ir::AliasTy::Opaque(opaque_ty.to_chalk(db)),
368 }
369 } 169 }
370 170
371 fn from_chalk(db: &dyn HirDatabase, chalk: Self::Chalk) -> Self { 171 fn from_chalk(db: &dyn HirDatabase, chalk: Self::Chalk) -> Self {
372 match chalk { 172 chalk
373 chalk_ir::AliasTy::Projection(projection_ty) => {
374 AliasTy::Projection(from_chalk(db, projection_ty))
375 }
376 chalk_ir::AliasTy::Opaque(opaque_ty) => AliasTy::Opaque(from_chalk(db, opaque_ty)),
377 }
378 } 173 }
379} 174}
380 175
@@ -382,11 +177,11 @@ impl ToChalk for AliasEq {
382 type Chalk = chalk_ir::AliasEq<Interner>; 177 type Chalk = chalk_ir::AliasEq<Interner>;
383 178
384 fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::AliasEq<Interner> { 179 fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::AliasEq<Interner> {
385 chalk_ir::AliasEq { alias: self.alias.to_chalk(db), ty: self.ty.to_chalk(db) } 180 self
386 } 181 }
387 182
388 fn from_chalk(db: &dyn HirDatabase, alias_eq: chalk_ir::AliasEq<Interner>) -> Self { 183 fn from_chalk(db: &dyn HirDatabase, alias_eq: chalk_ir::AliasEq<Interner>) -> Self {
389 AliasEq { alias: from_chalk(db, alias_eq.alias), ty: from_chalk(db, alias_eq.ty) } 184 alias_eq
390 } 185 }
391} 186}
392 187
@@ -394,68 +189,56 @@ impl ToChalk for DomainGoal {
394 type Chalk = chalk_ir::DomainGoal<Interner>; 189 type Chalk = chalk_ir::DomainGoal<Interner>;
395 190
396 fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::DomainGoal<Interner> { 191 fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::DomainGoal<Interner> {
397 match self { 192 self
398 DomainGoal::Holds(WhereClause::Implemented(tr)) => tr.to_chalk(db).cast(&Interner),
399 DomainGoal::Holds(WhereClause::AliasEq(alias_eq)) => {
400 alias_eq.to_chalk(db).cast(&Interner)
401 }
402 }
403 } 193 }
404 194
405 fn from_chalk(_db: &dyn HirDatabase, _goal: chalk_ir::DomainGoal<Interner>) -> Self { 195 fn from_chalk(_db: &dyn HirDatabase, goal: chalk_ir::DomainGoal<Interner>) -> Self {
406 unimplemented!() 196 goal
407 } 197 }
408} 198}
409 199
410impl<T> ToChalk for Canonical<T> 200impl<T> ToChalk for Canonical<T>
411where 201where
412 T: ToChalk, 202 T: HasInterner<Interner = Interner>,
413 T::Chalk: HasInterner<Interner = Interner>,
414{ 203{
415 type Chalk = chalk_ir::Canonical<T::Chalk>; 204 type Chalk = chalk_ir::Canonical<T>;
416 205
417 fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Canonical<T::Chalk> { 206 fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Canonical<T> {
418 let value = self.value.to_chalk(db); 207 self
419 chalk_ir::Canonical { value, binders: self.binders }
420 } 208 }
421 209
422 fn from_chalk(db: &dyn HirDatabase, canonical: chalk_ir::Canonical<T::Chalk>) -> Canonical<T> { 210 fn from_chalk(db: &dyn HirDatabase, canonical: chalk_ir::Canonical<T>) -> Canonical<T> {
423 Canonical { binders: canonical.binders, value: from_chalk(db, canonical.value) } 211 canonical
424 } 212 }
425} 213}
426 214
427impl<T: ToChalk> ToChalk for InEnvironment<T> 215impl<T: ToChalk> ToChalk for InEnvironment<T>
428where 216where
429 T::Chalk: chalk_ir::interner::HasInterner<Interner = Interner>, 217 T: HasInterner<Interner = Interner>,
430{ 218{
431 type Chalk = chalk_ir::InEnvironment<T::Chalk>; 219 type Chalk = chalk_ir::InEnvironment<T>;
432 220
433 fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::InEnvironment<T::Chalk> { 221 fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::InEnvironment<T> {
434 chalk_ir::InEnvironment { environment: self.environment, goal: self.goal.to_chalk(db) } 222 self
435 } 223 }
436 224
437 fn from_chalk( 225 fn from_chalk(_db: &dyn HirDatabase, in_env: chalk_ir::InEnvironment<T>) -> InEnvironment<T> {
438 _db: &dyn HirDatabase, 226 in_env
439 _in_env: chalk_ir::InEnvironment<T::Chalk>,
440 ) -> InEnvironment<T> {
441 unimplemented!()
442 } 227 }
443} 228}
444 229
445impl<T: ToChalk> ToChalk for crate::Binders<T> 230impl<T: ToChalk> ToChalk for crate::Binders<T>
446where 231where
447 T::Chalk: chalk_ir::interner::HasInterner<Interner = Interner>, 232 T: HasInterner<Interner = Interner>,
448{ 233{
449 type Chalk = chalk_ir::Binders<T::Chalk>; 234 type Chalk = chalk_ir::Binders<T>;
450 235
451 fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Binders<T::Chalk> { 236 fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Binders<T> {
452 let (value, binders) = self.into_value_and_skipped_binders(); 237 self
453 chalk_ir::Binders::new(binders, value.to_chalk(db))
454 } 238 }
455 239
456 fn from_chalk(db: &dyn HirDatabase, binders: chalk_ir::Binders<T::Chalk>) -> crate::Binders<T> { 240 fn from_chalk(db: &dyn HirDatabase, binders: chalk_ir::Binders<T>) -> crate::Binders<T> {
457 let (v, b) = binders.into_value_and_skipped_binders(); 241 binders
458 crate::Binders::new(b, from_chalk(db, v))
459 } 242 }
460} 243}
461 244
@@ -463,11 +246,11 @@ impl ToChalk for crate::ConstrainedSubst {
463 type Chalk = chalk_ir::ConstrainedSubst<Interner>; 246 type Chalk = chalk_ir::ConstrainedSubst<Interner>;
464 247
465 fn to_chalk(self, _db: &dyn HirDatabase) -> Self::Chalk { 248 fn to_chalk(self, _db: &dyn HirDatabase) -> Self::Chalk {
466 unimplemented!() 249 self
467 } 250 }
468 251
469 fn from_chalk(db: &dyn HirDatabase, chalk: Self::Chalk) -> Self { 252 fn from_chalk(db: &dyn HirDatabase, chalk: Self::Chalk) -> Self {
470 ConstrainedSubst { subst: from_chalk(db, chalk.subst) } 253 chalk
471 } 254 }
472} 255}
473 256