aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/traits/chalk
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_ty/src/traits/chalk')
-rw-r--r--crates/hir_ty/src/traits/chalk/mapping.rs32
1 files changed, 3 insertions, 29 deletions
diff --git a/crates/hir_ty/src/traits/chalk/mapping.rs b/crates/hir_ty/src/traits/chalk/mapping.rs
index 7209dd14e..aef6b8a15 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
@@ -478,10 +455,7 @@ where
478 type Chalk = chalk_ir::InEnvironment<T::Chalk>; 455 type Chalk = chalk_ir::InEnvironment<T::Chalk>;
479 456
480 fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::InEnvironment<T::Chalk> { 457 fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::InEnvironment<T::Chalk> {
481 chalk_ir::InEnvironment { 458 chalk_ir::InEnvironment { environment: self.environment, goal: self.goal.to_chalk(db) }
482 environment: self.environment.env.clone(),
483 goal: self.value.to_chalk(db),
484 }
485 } 459 }
486 460
487 fn from_chalk( 461 fn from_chalk(