Suggest {to,from}_ne_bytes for transmutations between arrays and integers, etc

This commit is contained in:
bendn
2025-03-31 15:50:56 +07:00
parent c02a4f0852
commit c8c074288a
52 changed files with 687 additions and 100 deletions

View File

@@ -158,6 +158,26 @@ pub(crate) struct MustNotSuspendReason {
pub reason: String,
}
pub(crate) struct UnnecessaryTransmute {
pub span: Span,
pub sugg: String,
pub help: Option<&'static str>,
}
// Needed for def_path_str
impl<'a> LintDiagnostic<'a, ()> for UnnecessaryTransmute {
fn decorate_lint<'b>(self, diag: &'b mut rustc_errors::Diag<'a, ()>) {
diag.primary_message(fluent::mir_transform_unnecessary_transmute);
diag.span_suggestion(
self.span,
"replace this with",
self.sugg,
lint::Applicability::MachineApplicable,
);
self.help.map(|help| diag.help(help));
}
}
#[derive(LintDiagnostic)]
#[diag(mir_transform_undefined_transmute)]
#[note]