diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-05-29 21:07:43 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-29 21:07:43 +0000 |
| commit | f7f01dd5f0a8254abeefb0156e2c4ebe1447bfb6 (patch) | |
| tree | 1a5a9c99f95f623ccdd8fb12c40649477196e8f5 | |
| parent | 3689c8c3f67ed8ed63674ef50c6022fc91db2e13 (diff) | |
| parent | 7d0586cb15000193941f93d4b5281e56ef751edd (diff) | |
| download | rust-f7f01dd5f0a8254abeefb0156e2c4ebe1447bfb6.tar.gz rust-f7f01dd5f0a8254abeefb0156e2c4ebe1447bfb6.zip | |
Merge #4651
4651: Use first match branch in case of type mismatch, not last r=kjeremy a=flodiebold 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. Co-authored-by: Florian Diebold <florian.diebold@freiheit.com>
| -rw-r--r-- | crates/ra_hir_ty/src/infer/coerce.rs | 4 | ||||
| -rw-r--r-- | crates/ra_hir_ty/src/tests/simple.rs | 2 |
2 files changed, 2 insertions, 4 deletions
diff --git a/crates/ra_hir_ty/src/infer/coerce.rs b/crates/ra_hir_ty/src/infer/coerce.rs index 2ee9adb1642..32c7c57cd61 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() } } } diff --git a/crates/ra_hir_ty/src/tests/simple.rs b/crates/ra_hir_ty/src/tests/simple.rs index f1db3416049..839491b9e28 100644 --- a/crates/ra_hir_ty/src/tests/simple.rs +++ b/crates/ra_hir_ty/src/tests/simple.rs @@ -957,7 +957,7 @@ fn main(foo: Foo) { 51..107 'if tru... }': () 54..58 'true': bool 59..67 '{ }': () - 73..107 'if fal... }': () + 73..107 'if fal... }': i32 76..81 'false': bool 82..107 '{ ... }': i32 92..95 'foo': Foo |
