about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPavel Grigorenko <GrigorenkoPV@ya.ru>2024-08-09 00:12:41 +0300
committerPavel Grigorenko <GrigorenkoPV@ya.ru>2024-08-10 14:32:55 +0300
commit1b6cc24c20557e1a34a5c889bd771924d5c572c5 (patch)
treea385941d10224914aa0870ff84c78abec2f5ab82
parent446e03e3c92dedcf90aea3069e40d19dae6772f2 (diff)
downloadrust-1b6cc24c20557e1a34a5c889bd771924d5c572c5.tar.gz
rust-1b6cc24c20557e1a34a5c889bd771924d5c572c5.zip
rustc_borrowck: make some suggestion about static lifetimes translatable
-rw-r--r--compiler/rustc_borrowck/messages.ftl6
-rw-r--r--compiler/rustc_borrowck/src/diagnostics/region_errors.rs5
2 files changed, 8 insertions, 3 deletions
diff --git a/compiler/rustc_borrowck/messages.ftl b/compiler/rustc_borrowck/messages.ftl
index 090bd2293d3..7eed4e379c8 100644
--- a/compiler/rustc_borrowck/messages.ftl
+++ b/compiler/rustc_borrowck/messages.ftl
@@ -80,6 +80,9 @@ borrowck_higher_ranked_subtype_error =
 borrowck_lifetime_constraints_error =
     lifetime may not live long enough
 
+borrowck_limitations_implies_static =
+    due to current limitations in the borrow checker, this implies a `'static` lifetime
+
 borrowck_move_closure_suggestion =
     consider adding 'move' keyword before the nested closure
 
@@ -169,6 +172,9 @@ borrowck_partial_var_move_by_use_in_coroutine =
         *[false] moved
     } due to use in coroutine
 
+borrowck_restrict_to_static =
+    consider restricting the type parameter to the `'static` lifetime
+
 borrowck_returned_async_block_escaped =
     returns an `async` block that contains a reference to a captured variable, which then escapes the closure body
 
diff --git a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs
index 74c74de3404..fe2a575ba8b 100644
--- a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs
+++ b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs
@@ -198,7 +198,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
     // from higher-ranked trait bounds (HRTB). Try to locate span of the trait
     // and the span which bounded to the trait for adding 'static lifetime suggestion
     #[allow(rustc::diagnostic_outside_of_impl)]
-    #[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
     fn suggest_static_lifetime_for_gat_from_hrtb(
         &self,
         diag: &mut Diag<'_>,
@@ -254,7 +253,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
             let Trait(PolyTraitRef { trait_ref, span: trait_span, .. }, _) = bound else { return; };
             diag.span_note(
                 *trait_span,
-                "due to current limitations in the borrow checker, this implies a `'static` lifetime"
+                fluent_generated::borrowck_limitations_implies_static,
             );
             let Some(generics_fn) = hir.get_generics(self.body.source.def_id().expect_local()) else { return; };
             let Def(_, trait_res_defid) = trait_ref.path.res else { return; };
@@ -286,7 +285,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
         if suggestions.len() > 0 {
             suggestions.dedup();
             diag.multipart_suggestion_verbose(
-                "consider restricting the type parameter to the `'static` lifetime",
+                fluent_generated::borrowck_restrict_to_static,
                 suggestions,
                 Applicability::MaybeIncorrect,
             );