From 4adfdea1ad5aca393fa5bb9ff40fdc05827fcd56 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Mon, 26 Aug 2019 23:00:35 +0300 Subject: Small fixes --- crates/ra_hir/src/ty/infer.rs | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'crates/ra_hir/src/ty') diff --git a/crates/ra_hir/src/ty/infer.rs b/crates/ra_hir/src/ty/infer.rs index 0aa993067..812990426 100644 --- a/crates/ra_hir/src/ty/infer.rs +++ b/crates/ra_hir/src/ty/infer.rs @@ -1009,16 +1009,12 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { let then_ty = self.infer_expr_inner(*then_branch, &expected); self.coerce(&then_ty, &expected.ty); - match else_branch { - Some(else_branch) => { - let else_ty = self.infer_expr_inner(*else_branch, &expected); - self.coerce(&else_ty, &expected.ty); - } - None => { - // no else branch -> unit - self.unify(&then_ty, &Ty::unit()); // actually coerce - } + + let else_ty = match else_branch { + Some(else_branch) => self.infer_expr_inner(*else_branch, &expected), + None => Ty::unit(), }; + self.coerce(&else_ty, &expected.ty); expected.ty.clone() } @@ -1422,7 +1418,8 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { } } } - let ty = if let Some(expr) = tail { self.infer_expr_inner(expr, expected) } else { Ty::unit() }; + let ty = + if let Some(expr) = tail { self.infer_expr_inner(expr, expected) } else { Ty::unit() }; ty } @@ -1665,8 +1662,8 @@ fn calculate_least_upper_bound(expected_ty: Ty, actual_tys: &[Ty]) -> Ty { all_never = false; least_upper_bound = match (actual_ty, &least_upper_bound) { (_, Ty::Unknown) - | (Ty::Infer(_), Ty::Infer(InferTy::TypeVar(_))) - | (Ty::Apply(_), _) => actual_ty.clone(), + | (Ty::Infer(_), Ty::Infer(InferTy::TypeVar(_))) + | (Ty::Apply(_), _) => actual_ty.clone(), _ => least_upper_bound, } } -- cgit v1.2.3