aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/infer
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_ty/src/infer')
-rw-r--r--crates/hir_ty/src/infer/expr.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/crates/hir_ty/src/infer/expr.rs b/crates/hir_ty/src/infer/expr.rs
index f73bf43b2..e34f194ff 100644
--- a/crates/hir_ty/src/infer/expr.rs
+++ b/crates/hir_ty/src/infer/expr.rs
@@ -337,10 +337,15 @@ impl<'a> InferenceContext<'a> {
337 Expr::Match { expr, arms } => { 337 Expr::Match { expr, arms } => {
338 let input_ty = self.infer_expr(*expr, &Expectation::none()); 338 let input_ty = self.infer_expr(*expr, &Expectation::none());
339 339
340 let expected = expected.adjust_for_branches(&mut self.table);
341
340 let mut result_ty = if arms.is_empty() { 342 let mut result_ty = if arms.is_empty() {
341 TyKind::Never.intern(&Interner) 343 TyKind::Never.intern(&Interner)
342 } else { 344 } else {
343 self.table.new_type_var() 345 match &expected {
346 Expectation::HasType(ty) => ty.clone(),
347 _ => self.table.new_type_var(),
348 }
344 }; 349 };
345 350
346 let matchee_diverges = self.diverges; 351 let matchee_diverges = self.diverges;