Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 1b6cc24

Browse files
committed
rustc_borrowck: make some suggestion about static lifetimes translatable
1 parent 446e03e commit 1b6cc24

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

compiler/rustc_borrowck/messages.ftl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ borrowck_higher_ranked_subtype_error =
8080
borrowck_lifetime_constraints_error =
8181
lifetime may not live long enough
8282
83+
borrowck_limitations_implies_static =
84+
due to current limitations in the borrow checker, this implies a `'static` lifetime
85+
8386
borrowck_move_closure_suggestion =
8487
consider adding 'move' keyword before the nested closure
8588
@@ -169,6 +172,9 @@ borrowck_partial_var_move_by_use_in_coroutine =
169172
*[false] moved
170173
} due to use in coroutine
171174
175+
borrowck_restrict_to_static =
176+
consider restricting the type parameter to the `'static` lifetime
177+
172178
borrowck_returned_async_block_escaped =
173179
returns an `async` block that contains a reference to a captured variable, which then escapes the closure body
174180

compiler/rustc_borrowck/src/diagnostics/region_errors.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
198198
// from higher-ranked trait bounds (HRTB). Try to locate span of the trait
199199
// and the span which bounded to the trait for adding 'static lifetime suggestion
200200
#[allow(rustc::diagnostic_outside_of_impl)]
201-
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
202201
fn suggest_static_lifetime_for_gat_from_hrtb(
203202
&self,
204203
diag: &mut Diag<'_>,
@@ -254,7 +253,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
254253
let Trait(PolyTraitRef { trait_ref, span: trait_span, .. }, _) = bound else { return; };
255254
diag.span_note(
256255
*trait_span,
257-
"due to current limitations in the borrow checker, this implies a `'static` lifetime"
256+
fluent_generated::borrowck_limitations_implies_static,
258257
);
259258
let Some(generics_fn) = hir.get_generics(self.body.source.def_id().expect_local()) else { return; };
260259
let Def(_, trait_res_defid) = trait_ref.path.res else { return; };
@@ -286,7 +285,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
286285
if suggestions.len() > 0 {
287286
suggestions.dedup();
288287
diag.multipart_suggestion_verbose(
289-
"consider restricting the type parameter to the `'static` lifetime",
288+
fluent_generated::borrowck_restrict_to_static,
290289
suggestions,
291290
Applicability::MaybeIncorrect,
292291
);

0 commit comments

Comments
 (0)