Rename inline_fluent! to msg!

This commit is contained in:
Jonathan Brouwer 2026-02-14 13:47:52 +01:00
parent 3f808f29e6
commit 018a5efcf7
No known key found for this signature in database
GPG key ID: 13619B051B673C52
64 changed files with 647 additions and 840 deletions

View file

@ -4,7 +4,7 @@
use std::num::NonZero;
use rustc_ast::NodeId;
use rustc_errors::{Applicability, Diag, EmissionGuarantee, LintBuffer, inline_fluent};
use rustc_errors::{Applicability, Diag, EmissionGuarantee, LintBuffer, msg};
use rustc_feature::GateIssue;
use rustc_hir::attrs::{DeprecatedSince, Deprecation};
use rustc_hir::def_id::{DefId, LocalDefId};
@ -128,20 +128,20 @@ pub struct Deprecated {
impl<'a, G: EmissionGuarantee> rustc_errors::LintDiagnostic<'a, G> for Deprecated {
fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, G>) {
diag.primary_message(match &self.since_kind {
DeprecatedSinceKind::InEffect => inline_fluent!(
DeprecatedSinceKind::InEffect => msg!(
"use of deprecated {$kind} `{$path}`{$has_note ->
[true] : {$note}
*[other] {\"\"}
}"
),
DeprecatedSinceKind::InFuture => inline_fluent!(
DeprecatedSinceKind::InFuture => msg!(
"use of {$kind} `{$path}` that will be deprecated in a future Rust version{$has_note ->
[true] : {$note}
*[other] {\"\"}
}"
),
DeprecatedSinceKind::InVersion(_) => {
inline_fluent!(
msg!(
"use of {$kind} `{$path}` that will be deprecated in future version {$version}{$has_note ->
[true] : {$note}
*[other] {\"\"}

View file

@ -337,25 +337,25 @@ impl<O> AssertKind<O> {
use AssertKind::*;
match self {
BoundsCheck { .. } => inline_fluent!(
"index out of bounds: the length is {$len} but the index is {$index}"
),
BoundsCheck { .. } => {
msg!("index out of bounds: the length is {$len} but the index is {$index}")
}
Overflow(BinOp::Shl, _, _) => {
inline_fluent!("attempt to shift left by `{$val}`, which would overflow")
msg!("attempt to shift left by `{$val}`, which would overflow")
}
Overflow(BinOp::Shr, _, _) => {
inline_fluent!("attempt to shift right by `{$val}`, which would overflow")
msg!("attempt to shift right by `{$val}`, which would overflow")
}
Overflow(_, _, _) => {
inline_fluent!("attempt to compute `{$left} {$op} {$right}`, which would overflow")
msg!("attempt to compute `{$left} {$op} {$right}`, which would overflow")
}
OverflowNeg(_) => msg!("attempt to negate `{$val}`, which would overflow"),
DivisionByZero(_) => msg!("attempt to divide `{$val}` by zero"),
RemainderByZero(_) => {
msg!("attempt to calculate the remainder of `{$val}` with a divisor of zero")
}
OverflowNeg(_) => inline_fluent!("attempt to negate `{$val}`, which would overflow"),
DivisionByZero(_) => inline_fluent!("attempt to divide `{$val}` by zero"),
RemainderByZero(_) => inline_fluent!(
"attempt to calculate the remainder of `{$val}` with a divisor of zero"
),
ResumedAfterReturn(CoroutineKind::Desugared(CoroutineDesugaring::Async, _)) => {
inline_fluent!("`async fn` resumed after completion")
msg!("`async fn` resumed after completion")
}
ResumedAfterReturn(CoroutineKind::Desugared(CoroutineDesugaring::AsyncGen, _)) => {
todo!()
@ -364,40 +364,38 @@ impl<O> AssertKind<O> {
bug!("gen blocks can be resumed after they return and will keep returning `None`")
}
ResumedAfterReturn(CoroutineKind::Coroutine(_)) => {
inline_fluent!("coroutine resumed after completion")
msg!("coroutine resumed after completion")
}
ResumedAfterPanic(CoroutineKind::Desugared(CoroutineDesugaring::Async, _)) => {
inline_fluent!("`async fn` resumed after panicking")
msg!("`async fn` resumed after panicking")
}
ResumedAfterPanic(CoroutineKind::Desugared(CoroutineDesugaring::AsyncGen, _)) => {
todo!()
}
ResumedAfterPanic(CoroutineKind::Desugared(CoroutineDesugaring::Gen, _)) => {
inline_fluent!("`gen` fn or block cannot be further iterated on after it panicked")
msg!("`gen` fn or block cannot be further iterated on after it panicked")
}
ResumedAfterPanic(CoroutineKind::Coroutine(_)) => {
inline_fluent!("coroutine resumed after panicking")
msg!("coroutine resumed after panicking")
}
NullPointerDereference => inline_fluent!("null pointer dereference occurred"),
NullPointerDereference => msg!("null pointer dereference occurred"),
InvalidEnumConstruction(_) => {
inline_fluent!("trying to construct an enum from an invalid value `{$source}`")
msg!("trying to construct an enum from an invalid value `{$source}`")
}
ResumedAfterDrop(CoroutineKind::Desugared(CoroutineDesugaring::Async, _)) => {
inline_fluent!("`async fn` resumed after async drop")
msg!("`async fn` resumed after async drop")
}
ResumedAfterDrop(CoroutineKind::Desugared(CoroutineDesugaring::AsyncGen, _)) => {
todo!()
}
ResumedAfterDrop(CoroutineKind::Desugared(CoroutineDesugaring::Gen, _)) => {
inline_fluent!(
"`gen` fn or block cannot be further iterated on after it async dropped"
)
msg!("`gen` fn or block cannot be further iterated on after it async dropped")
}
ResumedAfterDrop(CoroutineKind::Coroutine(_)) => {
inline_fluent!("coroutine resumed after async drop")
msg!("coroutine resumed after async drop")
}
MisalignedPointerDereference { .. } => inline_fluent!(
MisalignedPointerDereference { .. } => msg!(
"misaligned pointer dereference: address must be a multiple of {$required} but is {$found}"
),
}
@ -512,7 +510,7 @@ impl<'tcx> TerminatorKind<'tcx> {
}
pub use helper::*;
use rustc_errors::inline_fluent;
use rustc_errors::msg;
mod helper {
use super::*;

View file

@ -8,8 +8,7 @@ use rustc_abi::{
};
use rustc_error_messages::DiagMessage;
use rustc_errors::{
Diag, DiagArgValue, DiagCtxtHandle, Diagnostic, EmissionGuarantee, IntoDiagArg, Level,
inline_fluent,
Diag, DiagArgValue, DiagCtxtHandle, Diagnostic, EmissionGuarantee, IntoDiagArg, Level, msg,
};
use rustc_hir::LangItem;
use rustc_hir::def_id::DefId;
@ -270,24 +269,22 @@ impl<'tcx> LayoutError<'tcx> {
use LayoutError::*;
match self {
Unknown(_) => inline_fluent!("the type `{$ty}` has an unknown layout"),
Unknown(_) => msg!("the type `{$ty}` has an unknown layout"),
SizeOverflow(_) => {
inline_fluent!("values of the type `{$ty}` are too big for the target architecture")
msg!("values of the type `{$ty}` are too big for the target architecture")
}
InvalidSimd { kind: SimdLayoutError::TooManyLanes(_), .. } => {
inline_fluent!(
"the SIMD type `{$ty}` has more elements than the limit {$max_lanes}"
)
msg!("the SIMD type `{$ty}` has more elements than the limit {$max_lanes}")
}
InvalidSimd { kind: SimdLayoutError::ZeroLength, .. } => {
inline_fluent!("the SIMD type `{$ty}` has zero elements")
msg!("the SIMD type `{$ty}` has zero elements")
}
TooGeneric(_) => inline_fluent!("the type `{$ty}` does not have a fixed layout"),
NormalizationFailure(_, _) => inline_fluent!(
TooGeneric(_) => msg!("the type `{$ty}` does not have a fixed layout"),
NormalizationFailure(_, _) => msg!(
"unable to determine layout for `{$ty}` because `{$failure_ty}` cannot be normalized"
),
Cycle(_) => inline_fluent!("a cycle occurred during layout computation"),
ReferencesError(_) => inline_fluent!("the type has an unknown layout"),
Cycle(_) => msg!("a cycle occurred during layout computation"),
ReferencesError(_) => msg!("the type has an unknown layout"),
}
}