Don't let unknown match arms fall back to !

This commit is contained in:
Florian Diebold 2020-02-11 21:07:18 +01:00
parent 00e672a51b
commit 43df7c3d53
2 changed files with 22 additions and 1 deletions

View file

@ -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());