diff --git a/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs b/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs index 1ade0eb2e04c0..40a1ebd3f77f8 100644 --- a/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs +++ b/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs @@ -305,15 +305,14 @@ impl<'tcx> BorrowExplanation<'tcx> { }; err.subdiagnostic(sub_label); } else { - err.span_label( + //FIXME: src/test/ui/consts/const-eval/const-eval-intrinsic-promotion.rs + let sub_label = MustValidFor::Lasts { + category: category.description(), + borrow_desc, + region_name, span, - format!( - "{}requires that {}borrow lasts for `{}`", - category.description(), - borrow_desc, - region_name, - ), - ); + }; + err.subdiagnostic(sub_label); }; self.add_lifetime_bound_suggestion_to_diagnostic(err, &category, span, region_name); diff --git a/compiler/rustc_borrowck/src/session_diagnostics.rs b/compiler/rustc_borrowck/src/session_diagnostics.rs index d826a5dfff997..8131e40b721dd 100644 --- a/compiler/rustc_borrowck/src/session_diagnostics.rs +++ b/compiler/rustc_borrowck/src/session_diagnostics.rs @@ -321,4 +321,13 @@ pub(crate) enum MustValidFor<'a> { #[primary_span] span: Span, }, + + #[label(borrowck::outlive_constraint_need_borrow_lasts_for)] + Lasts { + category: &'a str, + borrow_desc: &'a str, + region_name: &'a RegionName, + #[primary_span] + span: Span, + }, }