From 638100dc8bea69cc4093d15f1641ed39a8d27a43 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sat, 29 Jun 2019 17:40:00 +0200 Subject: Refactor a bit & introduce Environment struct --- crates/ra_hir/src/ty/infer/unify.rs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'crates/ra_hir/src/ty/infer') diff --git a/crates/ra_hir/src/ty/infer/unify.rs b/crates/ra_hir/src/ty/infer/unify.rs index a24e5eb5c..ad2eefcaf 100644 --- a/crates/ra_hir/src/ty/infer/unify.rs +++ b/crates/ra_hir/src/ty/infer/unify.rs @@ -2,7 +2,9 @@ use super::InferenceContext; use crate::db::HirDatabase; -use crate::ty::{Canonical, InferTy, ProjectionPredicate, ProjectionTy, TraitRef, Ty}; +use crate::ty::{ + Canonical, InEnvironment, InferTy, ProjectionPredicate, ProjectionTy, TraitRef, Ty, +}; impl<'a, D: HirDatabase> InferenceContext<'a, D> { pub(super) fn canonicalizer<'b>(&'b mut self) -> Canonicalizer<'a, 'b, D> @@ -105,14 +107,24 @@ where ProjectionPredicate { ty, projection_ty } } + // FIXME: add some point, we need to introduce a `Fold` trait that abstracts + // over all the things that can be canonicalized (like Chalk and rustc have) + pub fn canonicalize_ty(mut self, ty: Ty) -> Canonicalized { let result = self.do_canonicalize_ty(ty); self.into_canonicalized(result) } - pub fn canonicalize_trait_ref(mut self, trait_ref: TraitRef) -> Canonicalized { - let result = self.do_canonicalize_trait_ref(trait_ref); - self.into_canonicalized(result) + pub fn canonicalize_trait_ref( + mut self, + trait_ref_in_env: InEnvironment, + ) -> Canonicalized> { + let result = self.do_canonicalize_trait_ref(trait_ref_in_env.value); + // FIXME canonicalize env + self.into_canonicalized(InEnvironment { + value: result, + environment: trait_ref_in_env.environment, + }) } pub fn canonicalize_projection( -- cgit v1.2.3