Skip to content

Commit 2ea9e1d

Browse files
committed
further simplify a match
1 parent 3f9cca3 commit 2ea9e1d

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

compiler/rustc_borrowck/src/diagnostics/region_errors.rs

+11-12
Original file line numberDiff line numberDiff line change
@@ -768,23 +768,22 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
768768
let outlived_fr_name = self.give_region_a_name(*outlived_fr).unwrap();
769769
outlived_fr_name.highlight_region_name(&mut diag);
770770

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-
}
771+
let err_category = if matches!(category, ConstraintCategory::Return(_))
772+
&& self.regioncx.universal_regions().is_local_free_region(*outlived_fr)
773+
{
774+
LifetimeReturnCategoryErr::WrongReturn {
775+
span: *span,
776+
mir_def_name,
777+
outlived_fr_name,
778+
fr_name: &fr_name,
781779
}
782-
_ => LifetimeReturnCategoryErr::ShortReturn {
780+
} else {
781+
LifetimeReturnCategoryErr::ShortReturn {
783782
span: *span,
784783
category_desc: category.description(),
785784
free_region_name: &fr_name,
786785
outlived_fr_name,
787-
},
786+
}
788787
};
789788

790789
diag.subdiagnostic(err_category);

0 commit comments

Comments
 (0)