Skip to content

Commit 3f9cca3

Browse files
committed
remove fr_is_local and outlived_fr_is_local fields from ErrorConstraintInfo
`fr_is_local` was fully unused, and `outlived_fr_is_local` was used once
1 parent c241e14 commit 3f9cca3

File tree

1 file changed

+14
-31
lines changed

1 file changed

+14
-31
lines changed

compiler/rustc_borrowck/src/diagnostics/region_errors.rs

+14-31
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,7 @@ pub(crate) enum RegionErrorKind<'tcx> {
147147
pub(crate) struct ErrorConstraintInfo<'tcx> {
148148
// fr: outlived_fr
149149
pub(super) fr: RegionVid,
150-
pub(super) fr_is_local: bool,
151150
pub(super) outlived_fr: RegionVid,
152-
pub(super) outlived_fr_is_local: bool,
153151

154152
// Category and span for best blame constraint
155153
pub(super) category: ConstraintCategory<'tcx>,
@@ -471,14 +469,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
471469
fr_is_local, outlived_fr_is_local, category
472470
);
473471

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 };
482473

483474
let mut diag = match (category, fr_is_local, outlived_fr_is_local) {
484475
(ConstraintCategory::Return(kind), true, false) if self.is_closure_fn_mut(fr) => {
@@ -680,11 +671,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
680671
&& self.regioncx.universal_regions().defining_ty.is_fn_def())
681672
|| self.regioncx.universal_regions().defining_ty.is_const()
682673
{
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);
688675
}
689676

690677
let mut diag =
@@ -762,15 +749,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
762749
/// ```
763750
#[allow(rustc::diagnostic_outside_of_impl)] // FIXME
764751
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;
774753

775754
let mir_def_name = self.infcx.tcx.def_descr(self.mir_def_id().to_def_id());
776755

@@ -789,13 +768,17 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
789768
let outlived_fr_name = self.give_region_a_name(*outlived_fr).unwrap();
790769
outlived_fr_name.highlight_region_name(&mut diag);
791770

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+
}
799782
_ => LifetimeReturnCategoryErr::ShortReturn {
800783
span: *span,
801784
category_desc: category.description(),

0 commit comments

Comments
 (0)