This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +17
-2
lines changed
compiler/rustc_infer/src/infer/error_reporting Expand file tree Collapse file tree 3 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -729,15 +729,15 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
729729 format ! ( "this and all prior arms are found to be of type `{}`" , t) ,
730730 ) ;
731731 }
732- let outer_error_span = if any_multiline_arm {
732+ let outer = if any_multiline_arm || !source_map . is_multiline ( cause . span ) {
733733 // Cover just `match` and the scrutinee expression, not
734734 // the entire match body, to reduce diagram noise.
735735 cause. span . shrink_to_lo ( ) . to ( scrut_span)
736736 } else {
737737 cause. span
738738 } ;
739739 let msg = "`match` arms have incompatible types" ;
740- err. span_label ( outer_error_span , msg) ;
740+ err. span_label ( outer , msg) ;
741741 self . suggest_remove_semi_or_return_binding (
742742 err,
743743 prior_arm_block_id,
Original file line number Diff line number Diff line change 1+ fn main ( ) {
2+ let _ = match Some ( 42 ) { Some ( x) => x, None => "" } ; //~ ERROR E0308
3+ }
Original file line number Diff line number Diff line change 1+ error[E0308]: `match` arms have incompatible types
2+ --> $DIR/single-line.rs:2:52
3+ |
4+ LL | let _ = match Some(42) { Some(x) => x, None => "" };
5+ | -------------- - ^^ expected integer, found `&str`
6+ | | |
7+ | | this is found to be of type `{integer}`
8+ | `match` arms have incompatible types
9+
10+ error: aborting due to previous error
11+
12+ For more information about this error, try `rustc --explain E0308`.
You can’t perform that action at this time.
0 commit comments