From f0dfeab43dae26a8406d78d883a7be0ad3824f24 Mon Sep 17 00:00:00 2001 From: David Wood Date: Thu, 11 Dec 2025 12:22:53 +0000 Subject: [PATCH] abi: `Display` bound on `TyAbiInterface` The `fmt::Debug` impl for `TyAndLayout<'a, Ty>'` requires `fmt::Display` on the `Ty` parameter. In `ArgAbi`, `TyAndLayout`'s Ty` is instantiated with a parameter that implements `TyAbiInterface`. `TyAbiInterface` only required `fmt::Debug` be implemented on `Self`, not `fmt::Display`, which meant that it wasn't actually possible to debug print `ArgAbi`. --- compiler/rustc_abi/src/callconv.rs | 1 + compiler/rustc_abi/src/layout/ty.rs | 2 +- compiler/rustc_target/src/callconv/aarch64.rs | 5 ++++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_abi/src/callconv.rs b/compiler/rustc_abi/src/callconv.rs index 1664b3003095..5b43a6c5881d 100644 --- a/compiler/rustc_abi/src/callconv.rs +++ b/compiler/rustc_abi/src/callconv.rs @@ -60,6 +60,7 @@ impl<'a, Ty> TyAndLayout<'a, Ty> { /// This is public so that it can be used in unit tests, but /// should generally only be relevant to the ABI details of /// specific targets. + #[tracing::instrument(skip(cx), level = "debug")] pub fn homogeneous_aggregate(&self, cx: &C) -> Result where Ty: TyAbiInterface<'a, C> + Copy, diff --git a/compiler/rustc_abi/src/layout/ty.rs b/compiler/rustc_abi/src/layout/ty.rs index a384eddc0b52..41ad14f550ab 100644 --- a/compiler/rustc_abi/src/layout/ty.rs +++ b/compiler/rustc_abi/src/layout/ty.rs @@ -155,7 +155,7 @@ impl<'a, Ty> AsRef> for TyAndLayout<'a, Ty> { /// Trait that needs to be implemented by the higher-level type representation /// (e.g. `rustc_middle::ty::Ty`), to provide `rustc_target::abi` functionality. -pub trait TyAbiInterface<'a, C>: Sized + std::fmt::Debug { +pub trait TyAbiInterface<'a, C>: Sized + std::fmt::Debug + std::fmt::Display { fn ty_and_layout_for_variant( this: TyAndLayout<'a, Self>, cx: &C, diff --git a/compiler/rustc_target/src/callconv/aarch64.rs b/compiler/rustc_target/src/callconv/aarch64.rs index b38d45551553..13be3888611f 100644 --- a/compiler/rustc_target/src/callconv/aarch64.rs +++ b/compiler/rustc_target/src/callconv/aarch64.rs @@ -9,13 +9,14 @@ use crate::spec::{Abi, HasTargetSpec, Target}; /// Used to accommodate Apple and Microsoft's deviations from the usual AAPCS ABI. /// /// Corresponds to Clang's `AArch64ABIInfo::ABIKind`. -#[derive(Copy, Clone, PartialEq)] +#[derive(Copy, Clone, Debug, PartialEq)] pub(crate) enum AbiKind { AAPCS, DarwinPCS, Win64, } +#[tracing::instrument(skip(cx), level = "debug")] fn is_homogeneous_aggregate<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'a, Ty>) -> Option where Ty: TyAbiInterface<'a, C> + Copy, @@ -73,6 +74,7 @@ fn softfloat_float_abi(target: &Target, arg: &mut ArgAbi<'_, Ty>) { } } +#[tracing::instrument(skip(cx), level = "debug")] fn classify_ret<'a, Ty, C>(cx: &C, ret: &mut ArgAbi<'a, Ty>, kind: AbiKind) where Ty: TyAbiInterface<'a, C> + Copy, @@ -105,6 +107,7 @@ where ret.make_indirect(); } +#[tracing::instrument(skip(cx), level = "debug")] fn classify_arg<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'a, Ty>, kind: AbiKind) where Ty: TyAbiInterface<'a, C> + Copy,