@@ -2,6 +2,7 @@ use crate::abi::{self, Abi, Align, FieldsShape, Size};
2
2
use crate :: abi:: { HasDataLayout , TyAbiInterface , TyAndLayout } ;
3
3
use crate :: spec:: { self , HasTargetSpec } ;
4
4
use rustc_span:: Symbol ;
5
+ use std:: fmt;
5
6
use std:: str:: FromStr ;
6
7
7
8
mod aarch64;
@@ -515,12 +516,20 @@ impl<'a, Ty> TyAndLayout<'a, Ty> {
515
516
516
517
/// Information about how to pass an argument to,
517
518
/// or return a value from, a function, under some ABI.
518
- #[ derive( Clone , PartialEq , Eq , Hash , Debug , HashStable_Generic ) ]
519
+ #[ derive( Clone , PartialEq , Eq , Hash , HashStable_Generic ) ]
519
520
pub struct ArgAbi < ' a , Ty > {
520
521
pub layout : TyAndLayout < ' a , Ty > ,
521
522
pub mode : PassMode ,
522
523
}
523
524
525
+ // Needs to be a custom impl because of the bounds on the `TyAndLayout` debug impl.
526
+ impl < ' a , Ty : fmt:: Display > fmt:: Debug for ArgAbi < ' a , Ty > {
527
+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
528
+ let ArgAbi { layout, mode } = self ;
529
+ f. debug_struct ( "ArgAbi" ) . field ( "layout" , layout) . field ( "mode" , mode) . finish ( )
530
+ }
531
+ }
532
+
524
533
impl < ' a , Ty > ArgAbi < ' a , Ty > {
525
534
/// This defines the "default ABI" for that type, that is then later adjusted in `fn_abi_adjust_for_abi`.
526
535
pub fn new (
@@ -694,7 +703,7 @@ impl RiscvInterruptKind {
694
703
///
695
704
/// I will do my best to describe this structure, but these
696
705
/// comments are reverse-engineered and may be inaccurate. -NDM
697
- #[ derive( Clone , PartialEq , Eq , Hash , Debug , HashStable_Generic ) ]
706
+ #[ derive( Clone , PartialEq , Eq , Hash , HashStable_Generic ) ]
698
707
pub struct FnAbi < ' a , Ty > {
699
708
/// The LLVM types of each argument.
700
709
pub args : Box < [ ArgAbi < ' a , Ty > ] > ,
@@ -715,6 +724,21 @@ pub struct FnAbi<'a, Ty> {
715
724
pub can_unwind : bool ,
716
725
}
717
726
727
+ // Needs to be a custom impl because of the bounds on the `TyAndLayout` debug impl.
728
+ impl < ' a , Ty : fmt:: Display > fmt:: Debug for FnAbi < ' a , Ty > {
729
+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
730
+ let FnAbi { args, ret, c_variadic, fixed_count, conv, can_unwind } = self ;
731
+ f. debug_struct ( "FnAbi" )
732
+ . field ( "args" , args)
733
+ . field ( "ret" , ret)
734
+ . field ( "c_variadic" , c_variadic)
735
+ . field ( "fixed_count" , fixed_count)
736
+ . field ( "conv" , conv)
737
+ . field ( "can_unwind" , can_unwind)
738
+ . finish ( )
739
+ }
740
+ }
741
+
718
742
/// Error produced by attempting to adjust a `FnAbi`, for a "foreign" ABI.
719
743
#[ derive( Copy , Clone , Debug , HashStable_Generic ) ]
720
744
pub enum AdjustForForeignAbiError {
0 commit comments