From 7d0586cb15000193941f93d4b5281e56ef751edd Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Fri, 29 May 2020 16:03:06 +0200 Subject: Use first match branch in case of type mismatch, not last The comment says this was intentional, but I do agree with #4304 that it makes more sense the other way around (for if/else as well). Fixes #4304. --- crates/ra_hir_ty/src/infer/coerce.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'crates/ra_hir_ty/src/infer/coerce.rs') diff --git a/crates/ra_hir_ty/src/infer/coerce.rs b/crates/ra_hir_ty/src/infer/coerce.rs index 2ee9adb16..32c7c57cd 100644 --- a/crates/ra_hir_ty/src/infer/coerce.rs +++ b/crates/ra_hir_ty/src/infer/coerce.rs @@ -45,9 +45,7 @@ impl<'a> InferenceContext<'a> { self.coerce_merge_branch(&ptr_ty1, &ptr_ty2) } else { mark::hit!(coerce_merge_fail_fallback); - // For incompatible types, we use the latter one as result - // to be better recovery for `if` without `else`. - ty2.clone() + ty1.clone() } } } -- cgit v1.2.3