Convert some impl Subdiagnostics to derives

This commit is contained in:
Jonathan Brouwer 2026-02-11 19:45:04 +01:00
parent 635dcd819a
commit ab4891ce74
No known key found for this signature in database
GPG key ID: 13619B051B673C52
3 changed files with 14 additions and 36 deletions

View file

@ -1975,27 +1975,17 @@ pub(crate) struct OverflowingBinHex<'a> {
pub sign_bit_sub: Option<OverflowingBinHexSignBitSub<'a>>,
}
#[derive(Subdiagnostic)]
pub(crate) enum OverflowingBinHexSign {
#[note(
"the literal `{$lit}` (decimal `{$dec}`) does not fit into the type `{$ty}` and will become `{$actually}{$ty}`"
)]
Positive,
#[note("the literal `{$lit}` (decimal `{$dec}`) does not fit into the type `{$ty}`")]
#[note("and the value `-{$lit}` will become `{$actually}{$ty}`")]
Negative,
}
impl Subdiagnostic for OverflowingBinHexSign {
fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
match self {
OverflowingBinHexSign::Positive => {
diag.note(inline_fluent!("the literal `{$lit}` (decimal `{$dec}`) does not fit into the type `{$ty}` and will become `{$actually}{$ty}`"));
}
OverflowingBinHexSign::Negative => {
diag.note(inline_fluent!(
"the literal `{$lit}` (decimal `{$dec}`) does not fit into the type `{$ty}`"
));
diag.note(inline_fluent!("and the value `-{$lit}` will become `{$actually}{$ty}`"));
}
}
}
}
#[derive(Subdiagnostic)]
pub(crate) enum OverflowingBinHexSub<'a> {
#[suggestion(