From 1481ab3f75573848a62a492b177054e8a96badfe Mon Sep 17 00:00:00 2001 From: Pavel Grigorenko Date: Fri, 9 Aug 2024 00:21:00 +0300 Subject: [PATCH] rustc_borrowck: make "implicit static" suff translatable --- compiler/rustc_borrowck/messages.ftl | 9 +++++++++ compiler/rustc_borrowck/src/diagnostics/region_errors.rs | 7 +++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_borrowck/messages.ftl b/compiler/rustc_borrowck/messages.ftl index 7eed4e379c8..edb25e12864 100644 --- a/compiler/rustc_borrowck/messages.ftl +++ b/compiler/rustc_borrowck/messages.ftl @@ -77,6 +77,15 @@ borrowck_higher_ranked_lifetime_error = borrowck_higher_ranked_subtype_error = higher-ranked subtype error +borrowck_implicit_static = + this has an implicit `'static` lifetime requirement + +borrowck_implicit_static_introduced = + calling this method introduces the `impl`'s `'static` requirement + +borrowck_implicit_static_relax = + consider relaxing the implicit `'static` requirement + borrowck_lifetime_constraints_error = lifetime may not live long enough diff --git a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs index fe2a575ba8b..a0be17e8b51 100644 --- a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs @@ -975,7 +975,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> { } #[allow(rustc::diagnostic_outside_of_impl)] - #[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable #[instrument(skip(self, err), level = "debug")] fn suggest_constrain_dyn_trait_in_impl( &self, @@ -994,15 +993,15 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> { for span in &traits { let mut multi_span: MultiSpan = vec![*span].into(); multi_span - .push_span_label(*span, "this has an implicit `'static` lifetime requirement"); + .push_span_label(*span, fluent_generated::borrowck_implicit_static); multi_span.push_span_label( ident.span, - "calling this method introduces the `impl`'s `'static` requirement", + fluent_generated::borrowck_implicit_static_introduced, ); err.subdiagnostic(RequireStaticErr::UsedImpl { multi_span }); err.span_suggestion_verbose( span.shrink_to_hi(), - "consider relaxing the implicit `'static` requirement", + fluent_generated::borrowck_implicit_static_relax, " + '_", Applicability::MaybeIncorrect, );