From a00fa0c06f70a377279ae77a01f19b05b3cb7437 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Wed, 10 Feb 2021 15:12:45 +0100 Subject: Put the old resolver back --- crates/hir_ty/src/infer/expr.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'crates/hir_ty') diff --git a/crates/hir_ty/src/infer/expr.rs b/crates/hir_ty/src/infer/expr.rs index d05c715e7..cb59a6937 100644 --- a/crates/hir_ty/src/infer/expr.rs +++ b/crates/hir_ty/src/infer/expr.rs @@ -138,8 +138,11 @@ impl<'a> InferenceContext<'a> { self.coerce_merge_branch(&then_ty, &else_ty) } Expr::Block { statements, tail, label, id: _ } => { - self.resolver = resolver_for_expr(self.db.upcast(), self.owner, tgt_expr); - match label { + let old_resolver = mem::replace( + &mut self.resolver, + resolver_for_expr(self.db.upcast(), self.owner, tgt_expr), + ); + let ty = match label { Some(_) => { let break_ty = self.table.new_type_var(); self.breakables.push(BreakableContext { @@ -157,7 +160,9 @@ impl<'a> InferenceContext<'a> { } } None => self.infer_block(statements, *tail, expected), - } + }; + self.resolver = old_resolver; + ty } Expr::Unsafe { body } | Expr::Const { body } => self.infer_expr(*body, expected), Expr::TryBlock { body } => { -- cgit v1.2.3