Account for match
expr in single line
When encountering `match Some(42) { Some(x) => x, None => "" };`, output ``` error[E0308]: `match` arms have incompatible types --> f53.rs:2:52 | 2 | let _ = match Some(42) { Some(x) => x, None => "" }; | -------------- - ^^ expected integer, found `&str` | | | | | this is found to be of type `{integer}` | `match` arms have incompatible types ```
This commit is contained in:
parent
92c1937a90
commit
05e8ba126c
3 changed files with 17 additions and 2 deletions
|
@ -729,7 +729,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
format!("this and all prior arms are found to be of type `{}`", t),
|
||||
);
|
||||
}
|
||||
let outer_error_span = if any_multiline_arm {
|
||||
let outer = if any_multiline_arm || !source_map.is_multiline(cause.span) {
|
||||
// Cover just `match` and the scrutinee expression, not
|
||||
// the entire match body, to reduce diagram noise.
|
||||
cause.span.shrink_to_lo().to(scrut_span)
|
||||
|
@ -737,7 +737,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
cause.span
|
||||
};
|
||||
let msg = "`match` arms have incompatible types";
|
||||
err.span_label(outer_error_span, msg);
|
||||
err.span_label(outer, msg);
|
||||
self.suggest_remove_semi_or_return_binding(
|
||||
err,
|
||||
prior_arm_block_id,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue