rustc_borrowck: make "implicit static" suff translatable

This commit is contained in:
Pavel Grigorenko 2024-08-09 00:21:00 +03:00
parent 1b6cc24c20
commit 1481ab3f75
2 changed files with 12 additions and 4 deletions

View File

@ -77,6 +77,15 @@ borrowck_higher_ranked_lifetime_error =
borrowck_higher_ranked_subtype_error = borrowck_higher_ranked_subtype_error =
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 = borrowck_lifetime_constraints_error =
lifetime may not live long enough lifetime may not live long enough

View File

@ -975,7 +975,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
} }
#[allow(rustc::diagnostic_outside_of_impl)] #[allow(rustc::diagnostic_outside_of_impl)]
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
#[instrument(skip(self, err), level = "debug")] #[instrument(skip(self, err), level = "debug")]
fn suggest_constrain_dyn_trait_in_impl( fn suggest_constrain_dyn_trait_in_impl(
&self, &self,
@ -994,15 +993,15 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
for span in &traits { for span in &traits {
let mut multi_span: MultiSpan = vec![*span].into(); let mut multi_span: MultiSpan = vec![*span].into();
multi_span 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( multi_span.push_span_label(
ident.span, ident.span,
"calling this method introduces the `impl`'s `'static` requirement", fluent_generated::borrowck_implicit_static_introduced,
); );
err.subdiagnostic(RequireStaticErr::UsedImpl { multi_span }); err.subdiagnostic(RequireStaticErr::UsedImpl { multi_span });
err.span_suggestion_verbose( err.span_suggestion_verbose(
span.shrink_to_hi(), span.shrink_to_hi(),
"consider relaxing the implicit `'static` requirement", fluent_generated::borrowck_implicit_static_relax,
" + '_", " + '_",
Applicability::MaybeIncorrect, Applicability::MaybeIncorrect,
); );