about summary refs log tree commit diff
path: root/compiler/rustc_errors/src/diagnostic_impls.rs
diff options
context:
space:
mode:
authorStuart Cook <Zalathar@users.noreply.github.com>2025-08-18 15:31:10 +1000
committerGitHub <noreply@github.com>2025-08-18 15:31:10 +1000
commitd92e1fe8d7c6d08e2921c40cfa38b625cb00a76d (patch)
tree2069a21ce7b8ff836f149ddb99c7e8f10bdfc9c9 /compiler/rustc_errors/src/diagnostic_impls.rs
parentb94842dcac322010d6ca4abf3baa68f702ec0706 (diff)
parent51bccdd1ab0802dd5a55bd06e956c8d547bdec2d (diff)
downloadrust-d92e1fe8d7c6d08e2921c40cfa38b625cb00a76d.tar.gz
rust-d92e1fe8d7c6d08e2921c40cfa38b625cb00a76d.zip
Rollup merge of #145206 - scrabsha:push-uxovoqzrxnlx, r=jdonszelmann
Port `#[custom_mir(..)]` to the new attribute system

r? ``````````@jdonszelmann``````````
Diffstat (limited to 'compiler/rustc_errors/src/diagnostic_impls.rs')
-rw-r--r--compiler/rustc_errors/src/diagnostic_impls.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/compiler/rustc_errors/src/diagnostic_impls.rs b/compiler/rustc_errors/src/diagnostic_impls.rs
index eca5806fac5..698b6b8d504 100644
--- a/compiler/rustc_errors/src/diagnostic_impls.rs
+++ b/compiler/rustc_errors/src/diagnostic_impls.rs
@@ -9,6 +9,7 @@ use rustc_abi::TargetDataLayoutErrors;
 use rustc_ast::util::parser::ExprPrecedence;
 use rustc_ast_pretty::pprust;
 use rustc_hir::RustcVersion;
+use rustc_hir::attrs::{MirDialect, MirPhase};
 use rustc_macros::Subdiagnostic;
 use rustc_span::edition::Edition;
 use rustc_span::{Ident, MacroRulesNormalizedIdent, Span, Symbol};
@@ -312,6 +313,28 @@ impl IntoDiagArg for ExprPrecedence {
     }
 }
 
+impl IntoDiagArg for MirDialect {
+    fn into_diag_arg(self, _path: &mut Option<PathBuf>) -> DiagArgValue {
+        let arg = match self {
+            MirDialect::Analysis => "analysis",
+            MirDialect::Built => "built",
+            MirDialect::Runtime => "runtime",
+        };
+        DiagArgValue::Str(Cow::Borrowed(arg))
+    }
+}
+
+impl IntoDiagArg for MirPhase {
+    fn into_diag_arg(self, _path: &mut Option<PathBuf>) -> DiagArgValue {
+        let arg = match self {
+            MirPhase::Initial => "initial",
+            MirPhase::PostCleanup => "post-cleanup",
+            MirPhase::Optimized => "optimized",
+        };
+        DiagArgValue::Str(Cow::Borrowed(arg))
+    }
+}
+
 #[derive(Clone)]
 pub struct DiagSymbolList<S = Symbol>(Vec<S>);