From f7be314579db29f64ef660aef1896da33d420ad6 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sun, 21 Mar 2021 20:05:38 +0100 Subject: Align Canonical more with Chalk's version In particular, use chalk_ir::CanonicalVarKinds. --- crates/hir_ty/src/traits/chalk/mapping.rs | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) (limited to 'crates/hir_ty/src/traits/chalk') 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 type Chalk = chalk_ir::Canonical; fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Canonical { - let kinds = self.kinds.iter().map(|&tk| { - chalk_ir::CanonicalVarKind::new( - chalk_ir::VariableKind::Ty(tk), - chalk_ir::UniverseIndex::ROOT, - ) - }); let value = self.value.to_chalk(db); - chalk_ir::Canonical { - value, - binders: chalk_ir::CanonicalVarKinds::from_iter(&Interner, kinds), - } + chalk_ir::Canonical { value, binders: self.binders } } fn from_chalk(db: &dyn HirDatabase, canonical: chalk_ir::Canonical) -> Canonical { - let kinds = canonical - .binders - .iter(&Interner) - .map(|k| match k.kind { - chalk_ir::VariableKind::Ty(tk) => tk, - // HACK: Chalk can sometimes return new lifetime variables. We - // want to just skip them, but to not mess up the indices of - // other variables, we'll just create a new type variable in - // their place instead. This should not matter (we never see the - // actual *uses* of the lifetime variable). - chalk_ir::VariableKind::Lifetime => chalk_ir::TyVariableKind::General, - chalk_ir::VariableKind::Const(_) => panic!("unexpected const from Chalk"), - }) - .collect(); - Canonical { kinds, value: from_chalk(db, canonical.value) } + Canonical { binders: canonical.binders, value: from_chalk(db, canonical.value) } } } -- cgit v1.2.3 From c4fd3f47f5b4f34476f8f085f2412a46aa0fd24f Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sun, 21 Mar 2021 20:19:07 +0100 Subject: Align InEnvironment with Chalk This in particular means storing a chalk_ir::Environment, not our TraitEnvironment. This makes InEnvironment not usable for Type, where we need to keep the full TraitEnvironment. --- crates/hir_ty/src/traits/chalk/mapping.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'crates/hir_ty/src/traits/chalk') diff --git a/crates/hir_ty/src/traits/chalk/mapping.rs b/crates/hir_ty/src/traits/chalk/mapping.rs index 58d8f2894..aef6b8a15 100644 --- a/crates/hir_ty/src/traits/chalk/mapping.rs +++ b/crates/hir_ty/src/traits/chalk/mapping.rs @@ -455,10 +455,7 @@ where type Chalk = chalk_ir::InEnvironment; fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::InEnvironment { - chalk_ir::InEnvironment { - environment: self.environment.env.clone(), - goal: self.value.to_chalk(db), - } + chalk_ir::InEnvironment { environment: self.environment, goal: self.goal.to_chalk(db) } } fn from_chalk( -- cgit v1.2.3