Skip to content

Commit bbde683

Browse files
committed
impl Display for Conv
1 parent b605c65 commit bbde683

File tree

3 files changed

+35
-4
lines changed

3 files changed

+35
-4
lines changed

compiler/rustc_const_eval/src/interpret/call.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,8 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
351351
if caller_fn_abi.conv != callee_fn_abi.conv {
352352
throw_ub_custom!(
353353
fluent::const_eval_incompatible_calling_conventions,
354-
callee_conv = format!("{:?}", callee_fn_abi.conv),
355-
caller_conv = format!("{:?}", caller_fn_abi.conv),
354+
callee_conv = format!("{}", callee_fn_abi.conv),
355+
caller_conv = format!("{}", caller_fn_abi.conv),
356356
)
357357
}
358358

compiler/rustc_target/src/callconv/mod.rs

+32
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use std::fmt::Display;
12
use std::str::FromStr;
23
use std::{fmt, iter};
34

@@ -881,6 +882,37 @@ impl FromStr for Conv {
881882
}
882883
}
883884

885+
impl Display for Conv {
886+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
887+
f.write_str(match self {
888+
Conv::C => "C",
889+
Conv::Rust => "Rust",
890+
Conv::Cold => "Cold",
891+
Conv::PreserveMost => "PreserveMost",
892+
Conv::PreserveAll => "PreserveAll",
893+
Conv::ArmAapcs => "ArmAapcs",
894+
Conv::CCmseNonSecureCall => "CCmseNonSecureCall",
895+
Conv::CCmseNonSecureEntry => "CCmseNonSecureEntry",
896+
Conv::Msp430Intr => "Msp430Intr",
897+
Conv::PtxKernel => "PtxKernel",
898+
Conv::GpuKernel => "GpuKernel",
899+
Conv::X86Fastcall => "X86Fastcall",
900+
Conv::X86Intr => "X86Intr",
901+
Conv::X86Stdcall => "X86Stdcall",
902+
Conv::X86ThisCall => "X86ThisCall",
903+
Conv::X86VectorCall => "X86VectorCall",
904+
Conv::X86_64SysV => "X86_64SysV",
905+
Conv::X86_64Win64 => "X86_64Win64",
906+
Conv::AvrInterrupt => "AvrInterrupt",
907+
Conv::AvrNonBlockingInterrupt => "AvrNonBlockingInterrupt",
908+
Conv::RiscvInterrupt { kind: RiscvInterruptKind::Machine } => "RiscvInterrupt(machine)",
909+
Conv::RiscvInterrupt { kind: RiscvInterruptKind::Supervisor } => {
910+
"RiscvInterrupt(supervisor)"
911+
}
912+
})
913+
}
914+
}
915+
884916
// Some types are used a lot. Make sure they don't unintentionally get bigger.
885917
#[cfg(target_pointer_width = "64")]
886918
mod size_asserts {

src/tools/miri/src/helpers.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -920,8 +920,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
920920
fn check_abi<'a>(&self, fn_abi: &FnAbi<'tcx, Ty<'tcx>>, exp_abi: Conv) -> InterpResult<'a, ()> {
921921
if fn_abi.conv != exp_abi {
922922
throw_ub_format!(
923-
"calling a function with ABI {:?} using caller ABI {:?}",
924-
exp_abi,
923+
"calling a function with ABI {exp_abi} using caller ABI {}",
925924
fn_abi.conv
926925
);
927926
}

0 commit comments

Comments
 (0)