about summary refs log tree commit diff
path: root/compiler/rustc_mir_transform/src/errors.rs
diff options
context:
space:
mode:
authorThe Miri Cronjob Bot <miri@cron.bot>2025-04-25 05:01:33 +0000
committerThe Miri Cronjob Bot <miri@cron.bot>2025-04-25 05:01:33 +0000
commit65e76849ac460cebfce6db7d6f3db6b48eeff31d (patch)
tree033589cdc25e12f84bf732fc1a3439208d9fee83 /compiler/rustc_mir_transform/src/errors.rs
parent37049558e43e72fa3890aa3f7c23e5f00414444c (diff)
parent7018392337a938e25c9ed9190c4f0966737fffdb (diff)
downloadrust-65e76849ac460cebfce6db7d6f3db6b48eeff31d.tar.gz
rust-65e76849ac460cebfce6db7d6f3db6b48eeff31d.zip
Merge from rustc
Diffstat (limited to 'compiler/rustc_mir_transform/src/errors.rs')
-rw-r--r--compiler/rustc_mir_transform/src/errors.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/compiler/rustc_mir_transform/src/errors.rs b/compiler/rustc_mir_transform/src/errors.rs
index 29698b0c2e4..5b03a4987ed 100644
--- a/compiler/rustc_mir_transform/src/errors.rs
+++ b/compiler/rustc_mir_transform/src/errors.rs
@@ -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]