From 43df7c3d53198e8ae3509035eb5273d8a94f758b Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Tue, 11 Feb 2020 21:07:18 +0100 Subject: Don't let unknown match arms fall back to ! --- crates/ra_hir_ty/src/infer/expr.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'crates/ra_hir_ty/src/infer') diff --git a/crates/ra_hir_ty/src/infer/expr.rs b/crates/ra_hir_ty/src/infer/expr.rs index 186857b8b..39d8bc0ca 100644 --- a/crates/ra_hir_ty/src/infer/expr.rs +++ b/crates/ra_hir_ty/src/infer/expr.rs @@ -165,7 +165,11 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { Expr::Match { expr, arms } => { let input_ty = self.infer_expr(*expr, &Expectation::none()); - let mut result_ty = self.table.new_maybe_never_type_var(); + let mut result_ty = if arms.len() == 0 { + Ty::simple(TypeCtor::Never) + } else { + self.table.new_type_var() + }; for arm in arms { let _pat_ty = self.infer_pat(arm.pat, &input_ty, BindingMode::default()); -- cgit v1.2.3