@@ -147,9 +147,7 @@ pub(crate) enum RegionErrorKind<'tcx> {
147
147
pub ( crate ) struct ErrorConstraintInfo < ' tcx > {
148
148
// fr: outlived_fr
149
149
pub ( super ) fr : RegionVid ,
150
- pub ( super ) fr_is_local : bool ,
151
150
pub ( super ) outlived_fr : RegionVid ,
152
- pub ( super ) outlived_fr_is_local : bool ,
153
151
154
152
// Category and span for best blame constraint
155
153
pub ( super ) category : ConstraintCategory < ' tcx > ,
@@ -471,14 +469,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
471
469
fr_is_local, outlived_fr_is_local, category
472
470
) ;
473
471
474
- let errci = ErrorConstraintInfo {
475
- fr,
476
- outlived_fr,
477
- fr_is_local,
478
- outlived_fr_is_local,
479
- category,
480
- span : cause. span ,
481
- } ;
472
+ let errci = ErrorConstraintInfo { fr, outlived_fr, category, span : cause. span } ;
482
473
483
474
let mut diag = match ( category, fr_is_local, outlived_fr_is_local) {
484
475
( ConstraintCategory :: Return ( kind) , true , false ) if self . is_closure_fn_mut ( fr) => {
@@ -680,11 +671,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
680
671
&& self . regioncx . universal_regions ( ) . defining_ty . is_fn_def ( ) )
681
672
|| self . regioncx . universal_regions ( ) . defining_ty . is_const ( )
682
673
{
683
- return self . report_general_error ( & ErrorConstraintInfo {
684
- fr_is_local : true ,
685
- outlived_fr_is_local : false ,
686
- ..* errci
687
- } ) ;
674
+ return self . report_general_error ( errci) ;
688
675
}
689
676
690
677
let mut diag =
@@ -762,15 +749,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
762
749
/// ```
763
750
#[ allow( rustc:: diagnostic_outside_of_impl) ] // FIXME
764
751
fn report_general_error ( & self , errci : & ErrorConstraintInfo < ' tcx > ) -> Diag < ' infcx > {
765
- let ErrorConstraintInfo {
766
- fr,
767
- fr_is_local,
768
- outlived_fr,
769
- outlived_fr_is_local,
770
- span,
771
- category,
772
- ..
773
- } = errci;
752
+ let ErrorConstraintInfo { fr, outlived_fr, span, category, .. } = errci;
774
753
775
754
let mir_def_name = self . infcx . tcx . def_descr ( self . mir_def_id ( ) . to_def_id ( ) ) ;
776
755
@@ -789,13 +768,17 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
789
768
let outlived_fr_name = self . give_region_a_name ( * outlived_fr) . unwrap ( ) ;
790
769
outlived_fr_name. highlight_region_name ( & mut diag) ;
791
770
792
- let err_category = match ( category, outlived_fr_is_local, fr_is_local) {
793
- ( ConstraintCategory :: Return ( _) , true , _) => LifetimeReturnCategoryErr :: WrongReturn {
794
- span : * span,
795
- mir_def_name,
796
- outlived_fr_name,
797
- fr_name : & fr_name,
798
- } ,
771
+ let err_category = match category {
772
+ ConstraintCategory :: Return ( _)
773
+ if self . regioncx . universal_regions ( ) . is_local_free_region ( * outlived_fr) =>
774
+ {
775
+ LifetimeReturnCategoryErr :: WrongReturn {
776
+ span : * span,
777
+ mir_def_name,
778
+ outlived_fr_name,
779
+ fr_name : & fr_name,
780
+ }
781
+ }
799
782
_ => LifetimeReturnCategoryErr :: ShortReturn {
800
783
span : * span,
801
784
category_desc : category. description ( ) ,
0 commit comments