Skip to content

Commit 701b194

Browse files
committed
impl Display for Conv
1 parent 0998d40 commit 701b194

File tree

3 files changed

+35
-4
lines changed

3 files changed

+35
-4
lines changed

compiler/rustc_const_eval/src/interpret/call.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,8 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
353353
if caller_fn_abi.conv != callee_fn_abi.conv {
354354
throw_ub_custom!(
355355
fluent::const_eval_incompatible_calling_conventions,
356-
callee_conv = format!("{:?}", callee_fn_abi.conv),
357-
caller_conv = format!("{:?}", caller_fn_abi.conv),
356+
callee_conv = format!("{}", callee_fn_abi.conv),
357+
caller_conv = format!("{}", caller_fn_abi.conv),
358358
)
359359
}
360360

compiler/rustc_target/src/callconv/mod.rs

Lines changed: 32 additions & 0 deletions
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

@@ -897,6 +898,37 @@ impl FromStr for Conv {
897898
}
898899
}
899900

901+
impl Display for Conv {
902+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
903+
f.write_str(match self {
904+
Conv::C => "C",
905+
Conv::Rust => "Rust",
906+
Conv::Cold => "Cold",
907+
Conv::PreserveMost => "PreserveMost",
908+
Conv::PreserveAll => "PreserveAll",
909+
Conv::ArmAapcs => "ArmAapcs",
910+
Conv::CCmseNonSecureCall => "CCmseNonSecureCall",
911+
Conv::CCmseNonSecureEntry => "CCmseNonSecureEntry",
912+
Conv::Msp430Intr => "Msp430Intr",
913+
Conv::PtxKernel => "PtxKernel",
914+
Conv::GpuKernel => "GpuKernel",
915+
Conv::X86Fastcall => "X86Fastcall",
916+
Conv::X86Intr => "X86Intr",
917+
Conv::X86Stdcall => "X86Stdcall",
918+
Conv::X86ThisCall => "X86ThisCall",
919+
Conv::X86VectorCall => "X86VectorCall",
920+
Conv::X86_64SysV => "X86_64SysV",
921+
Conv::X86_64Win64 => "X86_64Win64",
922+
Conv::AvrInterrupt => "AvrInterrupt",
923+
Conv::AvrNonBlockingInterrupt => "AvrNonBlockingInterrupt",
924+
Conv::RiscvInterrupt { kind: RiscvInterruptKind::Machine } => "RiscvInterrupt(machine)",
925+
Conv::RiscvInterrupt { kind: RiscvInterruptKind::Supervisor } => {
926+
"RiscvInterrupt(supervisor)"
927+
}
928+
})
929+
}
930+
}
931+
900932
// Some types are used a lot. Make sure they don't unintentionally get bigger.
901933
#[cfg(target_pointer_width = "64")]
902934
mod size_asserts {

src/tools/miri/src/helpers.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -932,8 +932,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
932932
fn check_abi<'a>(&self, fn_abi: &FnAbi<'tcx, Ty<'tcx>>, exp_abi: Conv) -> InterpResult<'a, ()> {
933933
if fn_abi.conv != exp_abi {
934934
throw_ub_format!(
935-
"calling a function with ABI {:?} using caller ABI {:?}",
936-
exp_abi,
935+
"calling a function with ABI {exp_abi} using caller ABI {}",
937936
fn_abi.conv
938937
);
939938
}

0 commit comments

Comments
 (0)