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> {
729
729
format ! ( "this and all prior arms are found to be of type `{}`" , t) ,
730
730
) ;
731
731
}
732
- let outer_error_span = if any_multiline_arm {
732
+ let outer = if any_multiline_arm || !source_map . is_multiline ( cause . span ) {
733
733
// Cover just `match` and the scrutinee expression, not
734
734
// the entire match body, to reduce diagram noise.
735
735
cause. span . shrink_to_lo ( ) . to ( scrut_span)
736
736
} else {
737
737
cause. span
738
738
} ;
739
739
let msg = "`match` arms have incompatible types" ;
740
- err. span_label ( outer_error_span , msg) ;
740
+ err. span_label ( outer , msg) ;
741
741
self . suggest_remove_semi_or_return_binding (
742
742
err,
743
743
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