From d8092147fe8a61d8068da4be1109f221e8155fa3 Mon Sep 17 00:00:00 2001 From: Jonathan Brouwer Date: Wed, 4 Mar 2026 15:23:36 +0100 Subject: [PATCH] Rename translation -> formatting --- .../rustc_borrowck/src/diagnostics/mod.rs | 2 +- compiler/rustc_builtin_macros/src/errors.rs | 6 ++-- compiler/rustc_codegen_llvm/src/errors.rs | 2 +- compiler/rustc_const_eval/src/errors.rs | 12 +++---- .../src/interpret/eval_context.rs | 2 +- .../src/annotate_snippet_emitter_writer.rs | 2 +- compiler/rustc_errors/src/diagnostic.rs | 8 ++--- compiler/rustc_errors/src/emitter.rs | 2 +- .../src/{translation.rs => formatting.rs} | 14 +++----- compiler/rustc_errors/src/json.rs | 14 ++++---- compiler/rustc_errors/src/lib.rs | 34 +++++++++---------- compiler/rustc_hir_typeck/src/errors.rs | 6 ++-- compiler/rustc_lint/src/if_let_rescope.rs | 2 +- compiler/rustc_lint/src/lints.rs | 2 +- .../src/diagnostics/subdiagnostic.rs | 2 +- .../src/lint_tail_expr_drop_order.rs | 4 +-- compiler/rustc_resolve/src/errors.rs | 2 +- compiler/rustc_trait_selection/src/errors.rs | 18 +++++----- .../src/errors/note_and_explain.rs | 2 +- .../passes/lint/check_code_block_syntax.rs | 2 +- triagebot.toml | 6 ++-- 21 files changed, 68 insertions(+), 76 deletions(-) rename compiler/rustc_errors/src/{translation.rs => formatting.rs} (79%) diff --git a/compiler/rustc_borrowck/src/diagnostics/mod.rs b/compiler/rustc_borrowck/src/diagnostics/mod.rs index ade3d928a0227..28be1a9fdf8eb 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mod.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mod.rs @@ -1310,7 +1310,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { { let mut span: MultiSpan = spans.clone().into(); err.arg("ty", param_ty.to_string()); - let msg = err.dcx.eagerly_translate_to_string( + let msg = err.dcx.eagerly_format_to_string( msg!("`{$ty}` is made to be an `FnOnce` closure here"), err.args.iter(), ); diff --git a/compiler/rustc_builtin_macros/src/errors.rs b/compiler/rustc_builtin_macros/src/errors.rs index f8b466373e0b3..961644b977592 100644 --- a/compiler/rustc_builtin_macros/src/errors.rs +++ b/compiler/rustc_builtin_macros/src/errors.rs @@ -764,7 +764,7 @@ pub(crate) struct FormatUnusedArg { impl Subdiagnostic for FormatUnusedArg { fn add_to_diag(self, diag: &mut Diag<'_, G>) { diag.arg("named", self.named); - let msg = diag.eagerly_translate(msg!( + let msg = diag.eagerly_format(msg!( "{$named -> [true] named argument *[false] argument @@ -947,8 +947,8 @@ pub(crate) struct AsmClobberNoReg { impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for AsmClobberNoReg { fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> { // eager translation as `span_labels` takes `AsRef` - let lbl1 = dcx.eagerly_translate_to_string(msg!("clobber_abi"), [].into_iter()); - let lbl2 = dcx.eagerly_translate_to_string(msg!("generic outputs"), [].into_iter()); + let lbl1 = dcx.eagerly_format_to_string(msg!("clobber_abi"), [].into_iter()); + let lbl2 = dcx.eagerly_format_to_string(msg!("generic outputs"), [].into_iter()); Diag::new( dcx, level, diff --git a/compiler/rustc_codegen_llvm/src/errors.rs b/compiler/rustc_codegen_llvm/src/errors.rs index af154a1aea80c..89bfdfbd9e579 100644 --- a/compiler/rustc_codegen_llvm/src/errors.rs +++ b/compiler/rustc_codegen_llvm/src/errors.rs @@ -24,7 +24,7 @@ impl Diagnostic<'_, G> for ParseTargetMachineConfig<'_> { fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> { let diag: Diag<'_, G> = self.0.into_diag(dcx, level); let (message, _) = diag.messages.first().expect("`LlvmError` with no message"); - let message = dcx.eagerly_translate_to_string(message.clone(), diag.args.iter()); + let message = dcx.eagerly_format_to_string(message.clone(), diag.args.iter()); Diag::new( dcx, level, diff --git a/compiler/rustc_const_eval/src/errors.rs b/compiler/rustc_const_eval/src/errors.rs index cdc02ae6933d2..4797b039c9624 100644 --- a/compiler/rustc_const_eval/src/errors.rs +++ b/compiler/rustc_const_eval/src/errors.rs @@ -366,7 +366,7 @@ impl Subdiagnostic for FrameNote { if self.has_label && !self.span.is_dummy() { span.push_span_label(self.span, msg!("the failure occurred here")); } - let msg = diag.eagerly_translate(msg!( + let msg = diag.eagerly_format(msg!( r#"{$times -> [0] inside {$where_ -> [closure] closure @@ -624,7 +624,7 @@ pub trait ReportErrorExt { let mut diag = dcx.struct_allow(DiagMessage::Str(String::new().into())); let message = self.diagnostic_message(); self.add_args(&mut diag); - let s = dcx.eagerly_translate_to_string(message, diag.args.iter()); + let s = dcx.eagerly_format_to_string(message, diag.args.iter()); diag.cancel(); s }) @@ -1086,12 +1086,12 @@ impl<'tcx> ReportErrorExt for ValidationErrorInfo<'tcx> { } let message = if let Some(path) = self.path { - err.dcx.eagerly_translate_to_string( + err.dcx.eagerly_format_to_string( msg!("constructing invalid value at {$path}"), [("path".into(), DiagArgValue::Str(path.into()))].iter().map(|(a, b)| (a, b)), ) } else { - err.dcx.eagerly_translate_to_string(msg!("constructing invalid value"), [].into_iter()) + err.dcx.eagerly_format_to_string(msg!("constructing invalid value"), [].into_iter()) }; err.arg("front_matter", message); @@ -1122,7 +1122,7 @@ impl<'tcx> ReportErrorExt for ValidationErrorInfo<'tcx> { ("hi".into(), DiagArgValue::Str(hi.to_string().into())), ]; let args = args.iter().map(|(a, b)| (a, b)); - let message = err.dcx.eagerly_translate_to_string(msg, args); + let message = err.dcx.eagerly_format_to_string(msg, args); err.arg("in_range", message); } @@ -1144,7 +1144,7 @@ impl<'tcx> ReportErrorExt for ValidationErrorInfo<'tcx> { ExpectedKind::EnumTag => msg!("expected a valid enum tag"), ExpectedKind::Str => msg!("expected a string"), }; - let msg = err.dcx.eagerly_translate_to_string(msg, [].into_iter()); + let msg = err.dcx.eagerly_format_to_string(msg, [].into_iter()); err.arg("expected", msg); } InvalidEnumTag { value } diff --git a/compiler/rustc_const_eval/src/interpret/eval_context.rs b/compiler/rustc_const_eval/src/interpret/eval_context.rs index 3a887f8afaa57..5ab69b9cb4627 100644 --- a/compiler/rustc_const_eval/src/interpret/eval_context.rs +++ b/compiler/rustc_const_eval/src/interpret/eval_context.rs @@ -235,7 +235,7 @@ pub fn format_interp_error<'tcx>(dcx: DiagCtxtHandle<'_>, e: InterpErrorInfo<'tc let mut diag = dcx.struct_allow(""); let msg = e.diagnostic_message(); e.add_args(&mut diag); - let s = dcx.eagerly_translate_to_string(msg, diag.args.iter()); + let s = dcx.eagerly_format_to_string(msg, diag.args.iter()); diag.cancel(); s } diff --git a/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs b/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs index 145937b22bea5..c3c9f26c31571 100644 --- a/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs +++ b/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs @@ -26,7 +26,7 @@ use crate::emitter::{ ConfusionType, Destination, MAX_SUGGESTIONS, OutputTheme, detect_confusion_type, is_different, normalize_whitespace, should_show_source_code, }; -use crate::translation::{format_diag_message, format_diag_messages}; +use crate::formatting::{format_diag_message, format_diag_messages}; use crate::{ CodeSuggestion, DiagInner, DiagMessage, Emitter, ErrCode, Level, MultiSpan, Style, Subdiag, SuggestionStyle, TerminalUrl, diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs index 888009bf9d4c5..0797ef3ec0d22 100644 --- a/compiler/rustc_errors/src/diagnostic.rs +++ b/compiler/rustc_errors/src/diagnostic.rs @@ -1143,7 +1143,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> { } } /// Add a subdiagnostic from a type that implements `Subdiagnostic` (see - /// [rustc_macros::Subdiagnostic]). Performs eager translation of any translatable messages + /// [rustc_macros::Subdiagnostic]). Performs eager formatting of any messages /// used in the subdiagnostic, so suitable for use with repeated messages (i.e. re-use of /// interpolated variables). pub fn subdiagnostic(&mut self, subdiagnostic: impl Subdiagnostic) -> &mut Self { @@ -1153,12 +1153,12 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> { /// Fluent variables are not namespaced from each other, so when /// `Diagnostic`s and `Subdiagnostic`s use the same variable name, - /// one value will clobber the other. Eagerly translating the + /// one value will clobber the other. Eagerly formatting the /// diagnostic uses the variables defined right then, before the /// clobbering occurs. - pub fn eagerly_translate(&self, msg: impl Into) -> DiagMessage { + pub fn eagerly_format(&self, msg: impl Into) -> DiagMessage { let args = self.args.iter(); - self.dcx.eagerly_translate(msg.into(), args) + self.dcx.eagerly_format(msg.into(), args) } with_fn! { with_span, diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index 8bb7dc35d82d4..fa3ff21b2726f 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -23,8 +23,8 @@ use rustc_span::source_map::SourceMap; use rustc_span::{FileName, SourceFile, Span}; use tracing::{debug, warn}; +use crate::formatting::format_diag_message; use crate::timings::TimingRecord; -use crate::translation::format_diag_message; use crate::{ CodeSuggestion, DiagInner, DiagMessage, Level, MultiSpan, Style, Subdiag, SuggestionStyle, }; diff --git a/compiler/rustc_errors/src/translation.rs b/compiler/rustc_errors/src/formatting.rs similarity index 79% rename from compiler/rustc_errors/src/translation.rs rename to compiler/rustc_errors/src/formatting.rs index 0de40cd84dcf9..1e0d9b7f5f92a 100644 --- a/compiler/rustc_errors/src/translation.rs +++ b/compiler/rustc_errors/src/formatting.rs @@ -8,10 +8,7 @@ use crate::fluent_bundle::FluentResource; use crate::{DiagArg, DiagMessage, Style, fluent_bundle}; /// Convert diagnostic arguments (a rustc internal type that exists to implement -/// `Encodable`/`Decodable`) into `FluentArgs` which is necessary to perform translation. -/// -/// Typically performed once for each diagnostic at the start of `emit_diagnostic` and then -/// passed around as a reference thereafter. +/// `Encodable`/`Decodable`) into `FluentArgs` which is necessary to perform formatting. fn to_fluent_args<'iter>(iter: impl Iterator>) -> FluentArgs<'static> { let mut args = if let Some(size) = iter.size_hint().1 { FluentArgs::with_capacity(size) @@ -40,9 +37,6 @@ pub fn format_diag_message<'a>(message: &'a DiagMessage, args: &DiagArgMap) -> C match message { DiagMessage::Str(msg) => Cow::Borrowed(msg), - // This translates an inline fluent diagnostic message - // It does this by creating a new `FluentBundle` with only one message, - // and then translating using this bundle. DiagMessage::Inline(msg) => { const GENERATED_MSG_ID: &str = "generated_msg"; let resource = @@ -56,10 +50,10 @@ pub fn format_diag_message<'a>(message: &'a DiagMessage, args: &DiagArgMap) -> C let args = to_fluent_args(args.iter()); let mut errs = vec![]; - let translated = bundle.format_pattern(value, Some(&args), &mut errs).to_string(); - debug!(?translated, ?errs); + let formatted = bundle.format_pattern(value, Some(&args), &mut errs).to_string(); + debug!(?formatted, ?errs); if errs.is_empty() { - Cow::Owned(translated) + Cow::Owned(formatted) } else { panic!("Fluent errors while formatting message: {errs:?}"); } diff --git a/compiler/rustc_errors/src/json.rs b/compiler/rustc_errors/src/json.rs index 3b266d058b14f..04ac140f33261 100644 --- a/compiler/rustc_errors/src/json.rs +++ b/compiler/rustc_errors/src/json.rs @@ -30,8 +30,8 @@ use crate::emitter::{ ColorConfig, Destination, Emitter, HumanReadableErrorType, OutputTheme, TimingEvent, should_show_source_code, }; +use crate::formatting::{format_diag_message, format_diag_messages}; use crate::timings::{TimingRecord, TimingSection}; -use crate::translation::{format_diag_message, format_diag_messages}; use crate::{CodeSuggestion, MultiSpan, SpanLabel, Subdiag, Suggestions, TerminalUrl}; #[cfg(test)] @@ -299,9 +299,9 @@ impl Diagnostic { /// Converts from `rustc_errors::DiagInner` to `Diagnostic`. fn from_errors_diagnostic(diag: crate::DiagInner, je: &JsonEmitter) -> Diagnostic { let sugg_to_diag = |sugg: &CodeSuggestion| { - let translated_message = format_diag_message(&sugg.msg, &diag.args); + let formatted_message = format_diag_message(&sugg.msg, &diag.args); Diagnostic { - message: translated_message.to_string(), + message: formatted_message.to_string(), code: None, level: "help", spans: DiagnosticSpan::from_suggestion(sugg, &diag.args, je), @@ -330,7 +330,7 @@ impl Diagnostic { } } - let translated_message = format_diag_messages(&diag.messages, &diag.args); + let formatted_message = format_diag_messages(&diag.messages, &diag.args); let code = if let Some(code) = diag.code { Some(DiagnosticCode { @@ -380,7 +380,7 @@ impl Diagnostic { let buf = String::from_utf8(buf).unwrap(); Diagnostic { - message: translated_message.to_string(), + message: formatted_message.to_string(), code, level, spans, @@ -390,9 +390,9 @@ impl Diagnostic { } fn from_sub_diagnostic(subdiag: &Subdiag, args: &DiagArgMap, je: &JsonEmitter) -> Diagnostic { - let translated_message = format_diag_messages(&subdiag.messages, args); + let formatted_message = format_diag_messages(&subdiag.messages, args); Diagnostic { - message: translated_message.to_string(), + message: formatted_message.to_string(), code: None, level: subdiag.level.to_str(), spans: DiagnosticSpan::from_multispan(&subdiag.span, args, je), diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index 4ef4d58074639..36494ab1a1f83 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -68,8 +68,8 @@ use rustc_span::{DUMMY_SP, Span}; use tracing::debug; use crate::emitter::TimingEvent; +use crate::formatting::format_diag_message; use crate::timings::TimingRecord; -use crate::translation::format_diag_message; pub mod annotate_snippet_emitter_writer; pub mod codes; @@ -77,11 +77,11 @@ mod decorate_diag; mod diagnostic; mod diagnostic_impls; pub mod emitter; +pub mod formatting; pub mod json; mod lock; pub mod markdown; pub mod timings; -pub mod translation; pub type PResult<'a, T> = Result>; @@ -484,24 +484,24 @@ impl DiagCtxt { self.inner.borrow_mut().emitter = emitter; } - /// Translate `message` eagerly with `args` to `DiagMessage::Eager`. - pub fn eagerly_translate<'a>( + /// Format `message` eagerly with `args` to `DiagMessage::Eager`. + pub fn eagerly_format<'a>( &self, message: DiagMessage, args: impl Iterator>, ) -> DiagMessage { let inner = self.inner.borrow(); - inner.eagerly_translate(message, args) + inner.eagerly_format(message, args) } - /// Translate `message` eagerly with `args` to `String`. - pub fn eagerly_translate_to_string<'a>( + /// Format `message` eagerly with `args` to `String`. + pub fn eagerly_format_to_string<'a>( &self, message: DiagMessage, args: impl Iterator>, ) -> String { let inner = self.inner.borrow(); - inner.eagerly_translate_to_string(message, args) + inner.eagerly_format_to_string(message, args) } // This is here to not allow mutation of flags; @@ -1419,17 +1419,17 @@ impl DiagCtxtInner { self.has_errors().or_else(|| self.delayed_bugs.get(0).map(|(_, guar)| guar).copied()) } - /// Translate `message` eagerly with `args` to `DiagMessage::Eager`. - fn eagerly_translate<'a>( + /// Format `message` eagerly with `args` to `DiagMessage::Eager`. + fn eagerly_format<'a>( &self, message: DiagMessage, args: impl Iterator>, ) -> DiagMessage { - DiagMessage::Str(Cow::from(self.eagerly_translate_to_string(message, args))) + DiagMessage::Str(Cow::from(self.eagerly_format_to_string(message, args))) } - /// Translate `message` eagerly with `args` to `String`. - fn eagerly_translate_to_string<'a>( + /// Format `message` eagerly with `args` to `String`. + fn eagerly_format_to_string<'a>( &self, message: DiagMessage, args: impl Iterator>, @@ -1438,12 +1438,12 @@ impl DiagCtxtInner { format_diag_message(&message, &args).to_string() } - fn eagerly_translate_for_subdiag( + fn eagerly_format_for_subdiag( &self, diag: &DiagInner, msg: impl Into, ) -> DiagMessage { - self.eagerly_translate(msg.into(), diag.args.iter()) + self.eagerly_format(msg.into(), diag.args.iter()) } fn flush_delayed(&mut self) { @@ -1509,7 +1509,7 @@ impl DiagCtxtInner { let msg = msg!( "`flushed_delayed` got diagnostic with level {$level}, instead of the expected `DelayedBug`" ); - let msg = self.eagerly_translate_for_subdiag(&bug, msg); // after the `arg` call + let msg = self.eagerly_format_for_subdiag(&bug, msg); // after the `arg` call bug.sub(Note, msg, bug.span.primary_span().unwrap().into()); } bug.level = Bug; @@ -1560,7 +1560,7 @@ impl DelayedDiagInner { }; diag.arg("emitted_at", diag.emitted_at.clone()); diag.arg("note", self.note); - let msg = dcx.eagerly_translate_for_subdiag(&diag, msg); // after the `arg` calls + let msg = dcx.eagerly_format_for_subdiag(&diag, msg); // after the `arg` calls diag.sub(Note, msg, diag.span.primary_span().unwrap_or(DUMMY_SP).into()); diag } diff --git a/compiler/rustc_hir_typeck/src/errors.rs b/compiler/rustc_hir_typeck/src/errors.rs index 0f33cf0b8433b..52f6b126a7d0e 100644 --- a/compiler/rustc_hir_typeck/src/errors.rs +++ b/compiler/rustc_hir_typeck/src/errors.rs @@ -987,13 +987,13 @@ impl rustc_errors::Subdiagnostic for CastUnknownPointerSub { fn add_to_diag(self, diag: &mut Diag<'_, G>) { match self { CastUnknownPointerSub::To(span) => { - let msg = diag.eagerly_translate(msg!("needs more type information")); + let msg = diag.eagerly_format(msg!("needs more type information")); diag.span_label(span, msg); - let msg = diag.eagerly_translate(msg!("the type information given here is insufficient to check whether the pointer cast is valid")); + let msg = diag.eagerly_format(msg!("the type information given here is insufficient to check whether the pointer cast is valid")); diag.note(msg); } CastUnknownPointerSub::From(span) => { - let msg = diag.eagerly_translate(msg!("the type information given here is insufficient to check whether the pointer cast is valid")); + let msg = diag.eagerly_format(msg!("the type information given here is insufficient to check whether the pointer cast is valid")); diag.span_label(span, msg); } } diff --git a/compiler/rustc_lint/src/if_let_rescope.rs b/compiler/rustc_lint/src/if_let_rescope.rs index ba196ef301c0d..0a754a7af03b2 100644 --- a/compiler/rustc_lint/src/if_let_rescope.rs +++ b/compiler/rustc_lint/src/if_let_rescope.rs @@ -354,7 +354,7 @@ impl Subdiagnostic for IfLetRescopeRewrite { .chain(repeat_n('}', closing_brackets.count)) .collect(), )); - let msg = diag.eagerly_translate(msg!( + let msg = diag.eagerly_format(msg!( "a `match` with a single arm can preserve the drop order up to Edition 2021" )); diag.multipart_suggestion_with_style( diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs index 40021debca0b4..5597c5b4c839a 100644 --- a/compiler/rustc_lint/src/lints.rs +++ b/compiler/rustc_lint/src/lints.rs @@ -3629,7 +3629,7 @@ impl Subdiagnostic for MismatchedLifetimeSyntaxesSuggestion { Explicit { lifetime_name, suggestions, optional_alternative } => { diag.arg("lifetime_name", lifetime_name); - let msg = diag.eagerly_translate(msg!("consistently use `{$lifetime_name}`")); + let msg = diag.eagerly_format(msg!("consistently use `{$lifetime_name}`")); diag.remove_arg("lifetime_name"); diag.multipart_suggestion_with_style( msg, diff --git a/compiler/rustc_macros/src/diagnostics/subdiagnostic.rs b/compiler/rustc_macros/src/diagnostics/subdiagnostic.rs index 5907e268e91b2..6237421322089 100644 --- a/compiler/rustc_macros/src/diagnostics/subdiagnostic.rs +++ b/compiler/rustc_macros/src/diagnostics/subdiagnostic.rs @@ -536,7 +536,7 @@ impl<'parent, 'a> SubdiagnosticDeriveVariantBuilder<'parent, 'a> { for (kind, messages) in kind_messages { let message = format_ident!("__message"); let message_stream = messages.diag_message(Some(self.variant)); - calls.extend(quote! { let #message = #diag.eagerly_translate(#message_stream); }); + calls.extend(quote! { let #message = #diag.eagerly_format(#message_stream); }); let name = format_ident!("{}{}", if span_field.is_some() { "span_" } else { "" }, kind); let call = match kind { diff --git a/compiler/rustc_mir_transform/src/lint_tail_expr_drop_order.rs b/compiler/rustc_mir_transform/src/lint_tail_expr_drop_order.rs index 03c459c312b67..c8d19f2e920a3 100644 --- a/compiler/rustc_mir_transform/src/lint_tail_expr_drop_order.rs +++ b/compiler/rustc_mir_transform/src/lint_tail_expr_drop_order.rs @@ -531,7 +531,7 @@ impl Subdiagnostic for LocalLabel<'_> { diag.arg("is_generated_name", self.is_generated_name); diag.remove_arg("is_dropped_first_edition_2024"); diag.arg("is_dropped_first_edition_2024", self.is_dropped_first_edition_2024); - let msg = diag.eagerly_translate(msg!( + let msg = diag.eagerly_format(msg!( "{$is_generated_name -> [true] this value will be stored in a temporary; let us call it `{$name}` *[false] `{$name}` calls a custom destructor @@ -542,7 +542,7 @@ impl Subdiagnostic for LocalLabel<'_> { dtor.add_to_diag(diag); } let msg = - diag.eagerly_translate(msg!( + diag.eagerly_format(msg!( "{$is_dropped_first_edition_2024 -> [true] up until Edition 2021 `{$name}` is dropped last but will be dropped earlier in Edition 2024 *[false] `{$name}` will be dropped later as of Edition 2024 diff --git a/compiler/rustc_resolve/src/errors.rs b/compiler/rustc_resolve/src/errors.rs index 2a0021ebc3bdc..54427535c5f6e 100644 --- a/compiler/rustc_resolve/src/errors.rs +++ b/compiler/rustc_resolve/src/errors.rs @@ -1366,7 +1366,7 @@ impl Subdiagnostic for FoundItemConfigureOut { ItemWas::BehindFeature { feature, span } => { let key = "feature".into(); let value = feature.into_diag_arg(&mut None); - let msg = diag.dcx.eagerly_translate_to_string( + let msg = diag.dcx.eagerly_format_to_string( msg!("the item is gated behind the `{$feature}` feature"), [(&key, &value)].into_iter(), ); diff --git a/compiler/rustc_trait_selection/src/errors.rs b/compiler/rustc_trait_selection/src/errors.rs index 03d24ebc20d3a..254a626ce2216 100644 --- a/compiler/rustc_trait_selection/src/errors.rs +++ b/compiler/rustc_trait_selection/src/errors.rs @@ -456,7 +456,7 @@ impl Subdiagnostic for RegionOriginNote<'_> { // See https://github.com/rust-lang/rust/issues/143872 for details. diag.store_args(); diag.arg("requirement", requirement); - let msg = diag.eagerly_translate(msg!( + let msg = diag.eagerly_format(msg!( "...so that the {$requirement -> [method_compat] method type is compatible with trait [type_compat] associated type is compatible with trait @@ -482,7 +482,7 @@ impl Subdiagnostic for RegionOriginNote<'_> { // *terrible*. diag.store_args(); diag.arg("requirement", requirement); - let msg = diag.eagerly_translate(msg!( + let msg = diag.eagerly_format(msg!( "...so that {$requirement -> [method_compat] method type is compatible with trait [type_compat] associated type is compatible with trait @@ -1174,7 +1174,7 @@ impl Subdiagnostic for ConsiderBorrowingParamHelp { type_param_span .push_span_label(span, msg!("consider borrowing this type parameter in the trait")); } - let msg = diag.eagerly_translate(msg!("the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`")); + let msg = diag.eagerly_format(msg!("the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`")); diag.span_help(type_param_span, msg); } } @@ -1218,10 +1218,9 @@ impl Subdiagnostic for DynTraitConstraintSuggestion { self.ident.span, msg!("calling this method introduces the `impl`'s `'static` requirement"), ); - let msg = diag.eagerly_translate(msg!("the used `impl` has a `'static` requirement")); + let msg = diag.eagerly_format(msg!("the used `impl` has a `'static` requirement")); diag.span_note(multi_span, msg); - let msg = - diag.eagerly_translate(msg!("consider relaxing the implicit `'static` requirement")); + let msg = diag.eagerly_format(msg!("consider relaxing the implicit `'static` requirement")); diag.span_suggestion_verbose( self.span.shrink_to_hi(), msg, @@ -1284,9 +1283,8 @@ impl Subdiagnostic for ReqIntroducedLocations { ); } self.span.push_span_label(self.cause_span, msg!("because of this returned expression")); - let msg = diag.eagerly_translate(msg!( - "\"`'static` lifetime requirement introduced by the return type" - )); + let msg = diag + .eagerly_format(msg!("\"`'static` lifetime requirement introduced by the return type")); diag.span_note(self.span, msg); } } @@ -1727,7 +1725,7 @@ impl Subdiagnostic for SuggestTuplePatternMany { fn add_to_diag(self, diag: &mut Diag<'_, G>) { diag.arg("path", self.path); let message = - diag.eagerly_translate(msg!("try wrapping the pattern in a variant of `{$path}`")); + diag.eagerly_format(msg!("try wrapping the pattern in a variant of `{$path}`")); diag.multipart_suggestions( message, self.compatible_variants.into_iter().map(|variant| { diff --git a/compiler/rustc_trait_selection/src/errors/note_and_explain.rs b/compiler/rustc_trait_selection/src/errors/note_and_explain.rs index 08618be03e75a..5121ca886c1bd 100644 --- a/compiler/rustc_trait_selection/src/errors/note_and_explain.rs +++ b/compiler/rustc_trait_selection/src/errors/note_and_explain.rs @@ -169,7 +169,7 @@ impl Subdiagnostic for RegionExplanation<'_> { diag.arg("desc_kind", self.desc.kind); diag.arg("desc_arg", self.desc.arg); - let msg = diag.eagerly_translate(msg!( + let msg = diag.eagerly_format(msg!( "{$pref_kind -> *[should_not_happen] [{$pref_kind}] [ref_valid_for] ...the reference is valid for diff --git a/src/librustdoc/passes/lint/check_code_block_syntax.rs b/src/librustdoc/passes/lint/check_code_block_syntax.rs index be1168b2eceec..e94fd996947b3 100644 --- a/src/librustdoc/passes/lint/check_code_block_syntax.rs +++ b/src/librustdoc/passes/lint/check_code_block_syntax.rs @@ -5,7 +5,7 @@ use std::sync::Arc; use rustc_data_structures::sync::Lock; use rustc_errors::emitter::Emitter; -use rustc_errors::translation::format_diag_message; +use rustc_errors::formatting::format_diag_message; use rustc_errors::{Applicability, DiagCtxt, DiagInner}; use rustc_parse::{source_str_to_stream, unwrap_or_emit_fatal}; use rustc_resolve::rustdoc::source_span_for_markdown_range; diff --git a/triagebot.toml b/triagebot.toml index b1675e00f0df7..0bcddeb144adc 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -534,7 +534,7 @@ trigger_files = [ [autolabel."A-translation"] trigger_files = [ "compiler/rustc_error_messages", - "compiler/rustc_errors/src/translation.rs", + "compiler/rustc_errors/src/formatting.rs", "compiler/rustc_macros/src/diagnostics" ] @@ -1180,8 +1180,8 @@ cc = ["@Muscraft"] message = "`rustc_errors::emitter` was changed" cc = ["@Muscraft"] -[mentions."compiler/rustc_errors/src/translation.rs"] -message = "`rustc_errors::translation` was changed" +[mentions."compiler/rustc_errors/src/formatting.rs"] +message = "`rustc_errors::formatting` was changed" cc = ["@davidtwco", "@TaKO8Ki", "@JonathanBrouwer"] [mentions."compiler/rustc_macros/src/diagnostics"]