From 9716c0b949b1a1a95b3f36928faed3abc21c0bda Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sun, 16 May 2021 18:27:17 +0200 Subject: Deal with goals arising from unification --- crates/hir_ty/src/infer/unify.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'crates/hir_ty/src/infer/unify.rs') diff --git a/crates/hir_ty/src/infer/unify.rs b/crates/hir_ty/src/infer/unify.rs index 539e12420..d872cdd58 100644 --- a/crates/hir_ty/src/infer/unify.rs +++ b/crates/hir_ty/src/infer/unify.rs @@ -307,12 +307,12 @@ impl<'a> InferenceTable<'a> { /// Unify two types and register new trait goals that arise from that. // TODO give these two functions better names pub(crate) fn unify(&mut self, ty1: &Ty, ty2: &Ty) -> bool { - let _result = if let Ok(r) = self.unify_inner(ty1, ty2) { + let result = if let Ok(r) = self.unify_inner(ty1, ty2) { r } else { return false; }; - // TODO deal with new goals + self.register_infer_ok(result); true } @@ -327,10 +327,7 @@ impl<'a> InferenceTable<'a> { t1, t2, ) { - Ok(_result) => { - // TODO deal with new goals - Ok(InferOk {}) - } + Ok(result) => Ok(InferOk { goals: result.goals }), Err(chalk_ir::NoSolution) => Err(TypeError), } } @@ -353,6 +350,10 @@ impl<'a> InferenceTable<'a> { } } + pub fn register_infer_ok(&mut self, infer_ok: InferOk) { + infer_ok.goals.into_iter().for_each(|goal| self.register_obligation_in_env(goal)); + } + pub fn resolve_obligations_as_possible(&mut self) { let _span = profile::span("resolve_obligations_as_possible"); let mut changed = true; -- cgit v1.2.3