@@ -392,7 +392,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
392
392
Some ( ty) if expected == ty => {
393
393
let source_map = self . tcx . sess . source_map ( ) ;
394
394
err. span_suggestion (
395
- source_map. end_point ( cause. span ( ) ) ,
395
+ source_map. end_point ( cause. span ) ,
396
396
"try removing this `?`" ,
397
397
"" ,
398
398
Applicability :: MachineApplicable ,
@@ -412,6 +412,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
412
412
source,
413
413
ref prior_non_diverging_arms,
414
414
scrut_span,
415
+ expr_span,
415
416
..
416
417
} ) => match source {
417
418
hir:: MatchSource :: TryDesugar ( scrut_hir_id) => {
@@ -430,7 +431,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
430
431
Some ( ty) if expected == ty => {
431
432
let source_map = self . tcx . sess . source_map ( ) ;
432
433
err. span_suggestion (
433
- source_map. end_point ( cause. span ( ) ) ,
434
+ source_map. end_point ( cause. span ) ,
434
435
"try removing this `?`" ,
435
436
"" ,
436
437
Applicability :: MachineApplicable ,
@@ -460,12 +461,12 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
460
461
format ! ( "this and all prior arms are found to be of type `{t}`" ) ,
461
462
) ;
462
463
}
463
- let outer = if any_multiline_arm || !source_map. is_multiline ( cause . span ) {
464
+ let outer = if any_multiline_arm || !source_map. is_multiline ( expr_span ) {
464
465
// Cover just `match` and the scrutinee expression, not
465
466
// the entire match body, to reduce diagram noise.
466
- cause . span . shrink_to_lo ( ) . to ( scrut_span)
467
+ expr_span . shrink_to_lo ( ) . to ( scrut_span)
467
468
} else {
468
- cause . span
469
+ expr_span
469
470
} ;
470
471
let msg = "`match` arms have incompatible types" ;
471
472
err. span_label ( outer, msg) ;
@@ -1148,7 +1149,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
1148
1149
terr : TypeError < ' tcx > ,
1149
1150
prefer_label : bool ,
1150
1151
) {
1151
- let span = cause. span ( ) ;
1152
+ let span = cause. span ;
1152
1153
1153
1154
// For some types of errors, expected-found does not make
1154
1155
// sense, so just ignore the values we were given.
@@ -1642,7 +1643,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
1642
1643
terr : TypeError < ' tcx > ,
1643
1644
) -> Vec < TypeErrorAdditionalDiags > {
1644
1645
let mut suggestions = Vec :: new ( ) ;
1645
- let span = trace. cause . span ( ) ;
1646
+ let span = trace. cause . span ;
1646
1647
let values = self . resolve_vars_if_possible ( trace. values ) ;
1647
1648
if let Some ( ( expected, found) ) = values. ty ( ) {
1648
1649
match ( expected. kind ( ) , found. kind ( ) ) {
@@ -1792,7 +1793,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
1792
1793
) -> Diag < ' a > {
1793
1794
debug ! ( "report_and_explain_type_error(trace={:?}, terr={:?})" , trace, terr) ;
1794
1795
1795
- let span = trace. cause . span ( ) ;
1796
+ let span = trace. cause . span ;
1796
1797
let failure_code = trace. cause . as_failure_code_diag (
1797
1798
terr,
1798
1799
span,
0 commit comments