Skip to content

Commit 5263438

Browse files
Convert to inline diagnostics in rustc_borrowck
1 parent 930ecbc commit 5263438

File tree

9 files changed

+233
-395
lines changed

9 files changed

+233
-395
lines changed

Cargo.lock

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3573,7 +3573,6 @@ dependencies = [
35733573
"rustc_abi",
35743574
"rustc_data_structures",
35753575
"rustc_errors",
3576-
"rustc_fluent_macro",
35773576
"rustc_graphviz",
35783577
"rustc_hir",
35793578
"rustc_index",
@@ -3778,7 +3777,6 @@ dependencies = [
37783777
"rustc_ast_lowering",
37793778
"rustc_ast_passes",
37803779
"rustc_ast_pretty",
3781-
"rustc_borrowck",
37823780
"rustc_builtin_macros",
37833781
"rustc_codegen_ssa",
37843782
"rustc_const_eval",

compiler/rustc_borrowck/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ polonius-engine = "0.13.0"
1111
rustc_abi = { path = "../rustc_abi" }
1212
rustc_data_structures = { path = "../rustc_data_structures" }
1313
rustc_errors = { path = "../rustc_errors" }
14-
rustc_fluent_macro = { path = "../rustc_fluent_macro" }
1514
rustc_graphviz = { path = "../rustc_graphviz" }
1615
rustc_hir = { path = "../rustc_hir" }
1716
rustc_index = { path = "../rustc_index" }

compiler/rustc_borrowck/messages.ftl

Lines changed: 0 additions & 296 deletions
This file was deleted.

compiler/rustc_borrowck/src/diagnostics/mod.rs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ use std::collections::BTreeMap;
44

55
use rustc_abi::{FieldIdx, VariantIdx};
66
use rustc_data_structures::fx::FxIndexMap;
7-
use rustc_errors::{Applicability, Diag, EmissionGuarantee, MultiSpan, listify};
7+
use rustc_errors::{
8+
Applicability, Diag, DiagMessage, EmissionGuarantee, MultiSpan, inline_fluent, listify,
9+
};
810
use rustc_hir::def::{CtorKind, Namespace};
911
use rustc_hir::{
1012
self as hir, CoroutineKind, GenericBound, LangItem, WhereBoundPredicate, WherePredicateKind,
@@ -35,7 +37,6 @@ use tracing::debug;
3537
use super::MirBorrowckCtxt;
3638
use super::borrow_set::BorrowData;
3739
use crate::constraints::OutlivesConstraint;
38-
use crate::fluent_generated as fluent;
3940
use crate::nll::ConstraintDescription;
4041
use crate::session_diagnostics::{
4142
CaptureArgLabel, CaptureReasonLabel, CaptureReasonNote, CaptureReasonSuggest, CaptureVarCause,
@@ -700,7 +701,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
700701
.rfind(|bgp| tcx.local_def_id_to_hir_id(bgp.def_id) == gat_hir_id)
701702
.is_some()
702703
{
703-
diag.span_note(pred.span, fluent::borrowck_limitations_implies_static);
704+
diag.span_note(pred.span, LIMITATION_NOTE);
704705
return;
705706
}
706707
for bound in bounds.iter() {
@@ -711,7 +712,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
711712
.rfind(|bgp| tcx.local_def_id_to_hir_id(bgp.def_id) == gat_hir_id)
712713
.is_some()
713714
{
714-
diag.span_note(bound.span, fluent::borrowck_limitations_implies_static);
715+
diag.span_note(bound.span, LIMITATION_NOTE);
715716
return;
716717
}
717718
}
@@ -1312,7 +1313,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
13121313
let mut span: MultiSpan = spans.clone().into();
13131314
err.arg("ty", param_ty.to_string());
13141315
let msg = err.dcx.eagerly_translate_to_string(
1315-
fluent::borrowck_moved_a_fn_once_in_call_def,
1316+
inline_fluent!("`{$ty}` is made to be an `FnOnce` closure here"),
13161317
err.args.iter(),
13171318
);
13181319
err.remove_arg("ty");
@@ -1321,9 +1322,12 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
13211322
}
13221323
span.push_span_label(
13231324
fn_call_span,
1324-
fluent::borrowck_moved_a_fn_once_in_call,
1325+
inline_fluent!("this value implements `FnOnce`, which causes it to be moved when called"),
1326+
);
1327+
err.span_note(
1328+
span,
1329+
inline_fluent!("`FnOnce` closures can only be called once"),
13251330
);
1326-
err.span_note(span, fluent::borrowck_moved_a_fn_once_in_call_call);
13271331
} else {
13281332
err.subdiagnostic(CaptureReasonNote::FnOnceMoveInCall { var_span });
13291333
}
@@ -1568,3 +1572,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
15681572
self.local_name(index).is_none_or(|name| name.as_str().starts_with('_'))
15691573
}
15701574
}
1575+
1576+
const LIMITATION_NOTE: DiagMessage = inline_fluent!(
1577+
"due to a current limitation of the type system, this implies a `'static` lifetime"
1578+
);

0 commit comments

Comments
 (0)