Skip to content

Commit 48413cf

Browse files
committed
rustc_borrowck: make dereference suggestion translatable
1 parent 6760298 commit 48413cf

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

compiler/rustc_borrowck/messages.ftl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ borrowck_could_not_normalize =
6262
borrowck_could_not_prove =
6363
could not prove `{$predicate}`
6464
65+
borrowck_dereference_suggestion =
66+
dereference the return value
67+
6568
borrowck_func_take_self_moved_place =
6669
`{$func}` takes ownership of the receiver `self`, which moves {$place_name}
6770

compiler/rustc_borrowck/src/diagnostics/region_errors.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use crate::session_diagnostics::{
3535
LifetimeReturnCategoryErr, RequireStaticErr, VarHereDenote,
3636
};
3737
use crate::universal_regions::DefiningTy;
38-
use crate::{borrowck_errors, MirBorrowckCtxt};
38+
use crate::{borrowck_errors, fluent_generated, MirBorrowckCtxt};
3939

4040
impl<'tcx> ConstraintDescription for ConstraintCategory<'tcx> {
4141
fn description(&self) -> &'static str {
@@ -1045,7 +1045,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
10451045
}
10461046

10471047
#[allow(rustc::diagnostic_outside_of_impl)]
1048-
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
10491048
/// When encountering a lifetime error caused by the return type of a closure, check the
10501049
/// corresponding trait bound and see if dereferencing the closure return value would satisfy
10511050
/// them. If so, we produce a structured suggestion.
@@ -1166,7 +1165,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
11661165
if ocx.select_all_or_error().is_empty() && count > 0 {
11671166
diag.span_suggestion_verbose(
11681167
tcx.hir().body(*body).value.peel_blocks().span.shrink_to_lo(),
1169-
"dereference the return value",
1168+
fluent_generated::borrowck_dereference_suggestion,
11701169
"*".repeat(count),
11711170
Applicability::MachineApplicable,
11721171
);

0 commit comments

Comments
 (0)