about summary refs log tree commit diff
diff options
context:
space:
mode:
authortiif <pekyuan@gmail.com>2025-01-21 08:08:58 +0000
committertiif <pekyuan@gmail.com>2025-03-12 14:38:51 +0000
commit701b1948abd46425ab588108bb406b7519ec16fa (patch)
tree74efd2718d56307d7656fd4c854f81669b826e61
parent0998d4095b0f11061f78a3f9c77a87838a4c1cb7 (diff)
downloadrust-701b1948abd46425ab588108bb406b7519ec16fa.tar.gz
rust-701b1948abd46425ab588108bb406b7519ec16fa.zip
impl Display for Conv
-rw-r--r--compiler/rustc_const_eval/src/interpret/call.rs4
-rw-r--r--compiler/rustc_target/src/callconv/mod.rs32
-rw-r--r--src/tools/miri/src/helpers.rs3
3 files changed, 35 insertions, 4 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/call.rs b/compiler/rustc_const_eval/src/interpret/call.rs
index 29f819cca1f..35e25187701 100644
--- a/compiler/rustc_const_eval/src/interpret/call.rs
+++ b/compiler/rustc_const_eval/src/interpret/call.rs
@@ -353,8 +353,8 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
         if caller_fn_abi.conv != callee_fn_abi.conv {
             throw_ub_custom!(
                 fluent::const_eval_incompatible_calling_conventions,
-                callee_conv = format!("{:?}", callee_fn_abi.conv),
-                caller_conv = format!("{:?}", caller_fn_abi.conv),
+                callee_conv = format!("{}", callee_fn_abi.conv),
+                caller_conv = format!("{}", caller_fn_abi.conv),
             )
         }
 
diff --git a/compiler/rustc_target/src/callconv/mod.rs b/compiler/rustc_target/src/callconv/mod.rs
index 6d0ee3c7ee5..0ea0d2d0173 100644
--- a/compiler/rustc_target/src/callconv/mod.rs
+++ b/compiler/rustc_target/src/callconv/mod.rs
@@ -1,3 +1,4 @@
+use std::fmt::Display;
 use std::str::FromStr;
 use std::{fmt, iter};
 
@@ -897,6 +898,37 @@ impl FromStr for Conv {
     }
 }
 
+impl Display for Conv {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+        f.write_str(match self {
+            Conv::C => "C",
+            Conv::Rust => "Rust",
+            Conv::Cold => "Cold",
+            Conv::PreserveMost => "PreserveMost",
+            Conv::PreserveAll => "PreserveAll",
+            Conv::ArmAapcs => "ArmAapcs",
+            Conv::CCmseNonSecureCall => "CCmseNonSecureCall",
+            Conv::CCmseNonSecureEntry => "CCmseNonSecureEntry",
+            Conv::Msp430Intr => "Msp430Intr",
+            Conv::PtxKernel => "PtxKernel",
+            Conv::GpuKernel => "GpuKernel",
+            Conv::X86Fastcall => "X86Fastcall",
+            Conv::X86Intr => "X86Intr",
+            Conv::X86Stdcall => "X86Stdcall",
+            Conv::X86ThisCall => "X86ThisCall",
+            Conv::X86VectorCall => "X86VectorCall",
+            Conv::X86_64SysV => "X86_64SysV",
+            Conv::X86_64Win64 => "X86_64Win64",
+            Conv::AvrInterrupt => "AvrInterrupt",
+            Conv::AvrNonBlockingInterrupt => "AvrNonBlockingInterrupt",
+            Conv::RiscvInterrupt { kind: RiscvInterruptKind::Machine } => "RiscvInterrupt(machine)",
+            Conv::RiscvInterrupt { kind: RiscvInterruptKind::Supervisor } => {
+                "RiscvInterrupt(supervisor)"
+            }
+        })
+    }
+}
+
 // Some types are used a lot. Make sure they don't unintentionally get bigger.
 #[cfg(target_pointer_width = "64")]
 mod size_asserts {
diff --git a/src/tools/miri/src/helpers.rs b/src/tools/miri/src/helpers.rs
index 12e7d0f1a62..bf08f9639c0 100644
--- a/src/tools/miri/src/helpers.rs
+++ b/src/tools/miri/src/helpers.rs
@@ -932,8 +932,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
     fn check_abi<'a>(&self, fn_abi: &FnAbi<'tcx, Ty<'tcx>>, exp_abi: Conv) -> InterpResult<'a, ()> {
         if fn_abi.conv != exp_abi {
             throw_ub_format!(
-                "calling a function with ABI {:?} using caller ABI {:?}",
-                exp_abi,
+                "calling a function with ABI {exp_abi} using caller ABI {}",
                 fn_abi.conv
             );
         }