aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/hir_ty/src/infer/expr.rs11
1 files changed, 8 insertions, 3 deletions
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> {
138 self.coerce_merge_branch(&then_ty, &else_ty) 138 self.coerce_merge_branch(&then_ty, &else_ty)
139 } 139 }
140 Expr::Block { statements, tail, label, id: _ } => { 140 Expr::Block { statements, tail, label, id: _ } => {
141 self.resolver = resolver_for_expr(self.db.upcast(), self.owner, tgt_expr); 141 let old_resolver = mem::replace(
142 match label { 142 &mut self.resolver,
143 resolver_for_expr(self.db.upcast(), self.owner, tgt_expr),
144 );
145 let ty = match label {
143 Some(_) => { 146 Some(_) => {
144 let break_ty = self.table.new_type_var(); 147 let break_ty = self.table.new_type_var();
145 self.breakables.push(BreakableContext { 148 self.breakables.push(BreakableContext {
@@ -157,7 +160,9 @@ impl<'a> InferenceContext<'a> {
157 } 160 }
158 } 161 }
159 None => self.infer_block(statements, *tail, expected), 162 None => self.infer_block(statements, *tail, expected),
160 } 163 };
164 self.resolver = old_resolver;
165 ty
161 } 166 }
162 Expr::Unsafe { body } | Expr::Const { body } => self.infer_expr(*body, expected), 167 Expr::Unsafe { body } | Expr::Const { body } => self.infer_expr(*body, expected),
163 Expr::TryBlock { body } => { 168 Expr::TryBlock { body } => {