@@ -428,6 +428,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
428428 generic_param_scope :  LocalDefId , 
429429 errors :  & [ RegionResolutionError < ' tcx > ] , 
430430 )  -> ErrorGuaranteed  { 
431+  assert ! ( !errors. is_empty( ) ) ; 
432+ 
431433 if  let  Some ( guaranteed)  = self . infcx . tainted_by_errors ( )  { 
432434 return  guaranteed; 
433435 } 
@@ -440,10 +442,13 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
440442
441443 debug ! ( "report_region_errors: {} errors after preprocessing" ,  errors. len( ) ) ; 
442444
445+  let  mut  guar = None ; 
443446 for  error in  errors { 
444447 debug ! ( "report_region_errors: error = {:?}" ,  error) ; 
445448
446-  if  !self . try_report_nice_region_error ( & error)  { 
449+  guar = Some ( if  let  Some ( guar)  = self . try_report_nice_region_error ( & error)  { 
450+  guar
451+  }  else  { 
447452 match  error. clone ( )  { 
448453 // These errors could indicate all manner of different 
449454 // problems with many different solutions. Rather 
@@ -454,21 +459,20 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
454459 // general bit of code that displays the error information 
455460 RegionResolutionError :: ConcreteFailure ( origin,  sub,  sup)  => { 
456461 if  sub. is_placeholder ( )  || sup. is_placeholder ( )  { 
457-  self . report_placeholder_failure ( origin,  sub,  sup) . emit ( ) ; 
462+  self . report_placeholder_failure ( origin,  sub,  sup) . emit ( ) 
458463 }  else  { 
459-  self . report_concrete_failure ( origin,  sub,  sup) . emit ( ) ; 
464+  self . report_concrete_failure ( origin,  sub,  sup) . emit ( ) 
460465 } 
461466 } 
462467
463-  RegionResolutionError :: GenericBoundFailure ( origin,  param_ty,  sub)  => { 
464-  self . report_generic_bound_failure ( 
468+  RegionResolutionError :: GenericBoundFailure ( origin,  param_ty,  sub)  => self 
469+  . report_generic_bound_failure ( 
465470 generic_param_scope, 
466471 origin. span ( ) , 
467472 Some ( origin) , 
468473 param_ty, 
469474 sub, 
470-  ) ; 
471-  } 
475+  ) , 
472476
473477 RegionResolutionError :: SubSupConflict ( 
474478 _, 
@@ -480,13 +484,13 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
480484 _, 
481485 )  => { 
482486 if  sub_r. is_placeholder ( )  { 
483-  self . report_placeholder_failure ( sub_origin,  sub_r,  sup_r) . emit ( ) ; 
487+  self . report_placeholder_failure ( sub_origin,  sub_r,  sup_r) . emit ( ) 
484488 }  else  if  sup_r. is_placeholder ( )  { 
485-  self . report_placeholder_failure ( sup_origin,  sub_r,  sup_r) . emit ( ) ; 
489+  self . report_placeholder_failure ( sup_origin,  sub_r,  sup_r) . emit ( ) 
486490 }  else  { 
487491 self . report_sub_sup_conflict ( 
488492 var_origin,  sub_origin,  sub_r,  sup_origin,  sup_r, 
489-  ) ; 
493+  ) 
490494 } 
491495 } 
492496
@@ -506,7 +510,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
506510 // value. 
507511 let  sub_r = self . tcx . lifetimes . re_erased ; 
508512
509-  self . report_placeholder_failure ( sup_origin,  sub_r,  sup_r) . emit ( ) ; 
513+  self . report_placeholder_failure ( sup_origin,  sub_r,  sup_r) . emit ( ) 
510514 } 
511515
512516 RegionResolutionError :: CannotNormalize ( clause,  origin)  => { 
@@ -515,15 +519,13 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
515519 self . tcx 
516520 . dcx ( ) 
517521 . struct_span_err ( origin. span ( ) ,  format ! ( "cannot normalize `{clause}`" ) ) 
518-  . emit ( ) ; 
522+  . emit ( ) 
519523 } 
520524 } 
521-  } 
525+  } ) 
522526 } 
523527
524-  self . tcx 
525-  . dcx ( ) 
526-  . span_delayed_bug ( self . tcx . def_span ( generic_param_scope) ,  "expected region errors" ) 
528+  guar. unwrap ( ) 
527529 } 
528530
529531 // This method goes through all the errors and try to group certain types 
@@ -2314,9 +2316,9 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
23142316 origin :  Option < SubregionOrigin < ' tcx > > , 
23152317 bound_kind :  GenericKind < ' tcx > , 
23162318 sub :  Region < ' tcx > , 
2317-  )  { 
2319+  )  ->  ErrorGuaranteed   { 
23182320 self . construct_generic_bound_failure ( generic_param_scope,  span,  origin,  bound_kind,  sub) 
2319-  . emit ( ) ; 
2321+  . emit ( ) 
23202322 } 
23212323
23222324 pub  fn  construct_generic_bound_failure ( 
@@ -2575,7 +2577,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
25752577 sub_region :  Region < ' tcx > , 
25762578 sup_origin :  SubregionOrigin < ' tcx > , 
25772579 sup_region :  Region < ' tcx > , 
2578-  )  { 
2580+  )  ->  ErrorGuaranteed   { 
25792581 let  mut  err = self . report_inference_failure ( var_origin) ; 
25802582
25812583 note_and_explain_region ( 
@@ -2614,12 +2616,11 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
26142616 ) ; 
26152617
26162618 err. note_expected_found ( & "" ,  sup_expected,  & "" ,  sup_found) ; 
2617-  if  sub_region. is_error ( )  | sup_region. is_error ( )  { 
2618-  err. delay_as_bug ( ) ; 
2619+  return   if  sub_region. is_error ( )  | sup_region. is_error ( )  { 
2620+  err. delay_as_bug ( ) 
26192621 }  else  { 
2620-  err. emit ( ) ; 
2621-  } 
2622-  return ; 
2622+  err. emit ( ) 
2623+  } ; 
26232624 } 
26242625
26252626 self . note_region_origin ( & mut  err,  & sup_origin) ; 
@@ -2634,11 +2635,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
26342635 ) ; 
26352636
26362637 self . note_region_origin ( & mut  err,  & sub_origin) ; 
2637-  if  sub_region. is_error ( )  | sup_region. is_error ( )  { 
2638-  err. delay_as_bug ( ) ; 
2639-  }  else  { 
2640-  err. emit ( ) ; 
2641-  } 
2638+  if  sub_region. is_error ( )  | sup_region. is_error ( )  {  err. delay_as_bug ( )  }  else  {  err. emit ( )  } 
26422639 } 
26432640
26442641 /// Determine whether an error associated with the given span and definition 
0 commit comments