Span body of last branch in exhaustiveness checking

Closes #4028
This commit is contained in:
Ayaz Hafiz 2022-09-13 16:24:34 -04:00
parent 3ee3f23836
commit 42633c1f96
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
2 changed files with 2 additions and 5 deletions

View file

@ -724,11 +724,7 @@ pub fn constrain_expr(
let branches_region = {
debug_assert!(!branches.is_empty());
Region::span_across(
&loc_cond.region,
// &branches.first().unwrap().region(),
&branches.last().unwrap().pattern_region(),
)
Region::span_across(&loc_cond.region, &branches.last().unwrap().value.region)
};
let branch_expr_reason =

View file

@ -10375,6 +10375,7 @@ All branches in an `if` must have the same type!
8 Ok "foo"
9
10 Bad _ ->
11 Ok "foo"
This `u8` value is a: