diff options
Diffstat (limited to 'crates/hir_ty/src/traits/chalk/mapping.rs')
-rw-r--r-- | crates/hir_ty/src/traits/chalk/mapping.rs | 27 |
1 files changed, 2 insertions, 25 deletions
diff --git a/crates/hir_ty/src/traits/chalk/mapping.rs b/crates/hir_ty/src/traits/chalk/mapping.rs index 7209dd14e..58d8f2894 100644 --- a/crates/hir_ty/src/traits/chalk/mapping.rs +++ b/crates/hir_ty/src/traits/chalk/mapping.rs | |||
@@ -439,35 +439,12 @@ where | |||
439 | type Chalk = chalk_ir::Canonical<T::Chalk>; | 439 | type Chalk = chalk_ir::Canonical<T::Chalk>; |
440 | 440 | ||
441 | fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Canonical<T::Chalk> { | 441 | fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Canonical<T::Chalk> { |
442 | let kinds = self.kinds.iter().map(|&tk| { | ||
443 | chalk_ir::CanonicalVarKind::new( | ||
444 | chalk_ir::VariableKind::Ty(tk), | ||
445 | chalk_ir::UniverseIndex::ROOT, | ||
446 | ) | ||
447 | }); | ||
448 | let value = self.value.to_chalk(db); | 442 | let value = self.value.to_chalk(db); |
449 | chalk_ir::Canonical { | 443 | chalk_ir::Canonical { value, binders: self.binders } |
450 | value, | ||
451 | binders: chalk_ir::CanonicalVarKinds::from_iter(&Interner, kinds), | ||
452 | } | ||
453 | } | 444 | } |
454 | 445 | ||
455 | fn from_chalk(db: &dyn HirDatabase, canonical: chalk_ir::Canonical<T::Chalk>) -> Canonical<T> { | 446 | fn from_chalk(db: &dyn HirDatabase, canonical: chalk_ir::Canonical<T::Chalk>) -> Canonical<T> { |
456 | let kinds = canonical | 447 | Canonical { binders: canonical.binders, value: from_chalk(db, canonical.value) } |
457 | .binders | ||
458 | .iter(&Interner) | ||
459 | .map(|k| match k.kind { | ||
460 | chalk_ir::VariableKind::Ty(tk) => tk, | ||
461 | // HACK: Chalk can sometimes return new lifetime variables. We | ||
462 | // want to just skip them, but to not mess up the indices of | ||
463 | // other variables, we'll just create a new type variable in | ||
464 | // their place instead. This should not matter (we never see the | ||
465 | // actual *uses* of the lifetime variable). | ||
466 | chalk_ir::VariableKind::Lifetime => chalk_ir::TyVariableKind::General, | ||
467 | chalk_ir::VariableKind::Const(_) => panic!("unexpected const from Chalk"), | ||
468 | }) | ||
469 | .collect(); | ||
470 | Canonical { kinds, value: from_chalk(db, canonical.value) } | ||
471 | } | 448 | } |
472 | } | 449 | } |
473 | 450 | ||