about summary refs log tree commit diff
path: root/compiler/rustc_mir_transform/src/errors.rs
diff options
context:
space:
mode:
authorThe rustc-dev-guide Cronjob Bot <github-actions@github.com>2025-04-28 04:02:54 +0000
committerThe rustc-dev-guide Cronjob Bot <github-actions@github.com>2025-04-28 04:02:54 +0000
commitaa15830ee2defbac8e784db5510bb914e6e4c820 (patch)
tree87e76fd223f1937ee26537e1028d44e7f6b65544 /compiler/rustc_mir_transform/src/errors.rs
parentde491f9b7827961c9a786a562cd996db68bd3b5d (diff)
parentdeb947971c8748f5c6203548ce4af9022f21eaf0 (diff)
downloadrust-aa15830ee2defbac8e784db5510bb914e6e4c820.tar.gz
rust-aa15830ee2defbac8e784db5510bb914e6e4c820.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]