@@ -107,6 +107,8 @@ pub enum Scalar<Tag = (), Id = AllocId> {
107
107
#[ cfg( target_arch = "x86_64" ) ]
108
108
static_assert_size ! ( Scalar , 24 ) ;
109
109
110
+ // We want the `Debug` output to be readable as it is used by `derive(Debug)` for
111
+ // all the Miri types.
110
112
impl < Tag : fmt:: Debug , Id : fmt:: Debug > fmt:: Debug for Scalar < Tag , Id > {
111
113
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
112
114
match self {
@@ -125,11 +127,11 @@ impl<Tag: fmt::Debug, Id: fmt::Debug> fmt::Debug for Scalar<Tag, Id> {
125
127
}
126
128
}
127
129
128
- impl < Tag > fmt:: Display for Scalar < Tag > {
130
+ impl < Tag : fmt :: Debug > fmt:: Display for Scalar < Tag > {
129
131
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
130
132
match self {
131
- Scalar :: Ptr ( _ ) => write ! ( f, "a pointer" ) ,
132
- Scalar :: Raw { data , .. } => write ! ( f , "{}" , data ) ,
133
+ Scalar :: Ptr ( ptr ) => write ! ( f, "pointer to {}" , ptr ) ,
134
+ Scalar :: Raw { .. } => fmt :: Debug :: fmt ( self , f ) ,
133
135
}
134
136
}
135
137
}
@@ -559,16 +561,18 @@ impl<Tag> From<Pointer<Tag>> for ScalarMaybeUndef<Tag> {
559
561
}
560
562
}
561
563
564
+ // We want the `Debug` output to be readable as it is used by `derive(Debug)` for
565
+ // all the Miri types.
562
566
impl < Tag : fmt:: Debug , Id : fmt:: Debug > fmt:: Debug for ScalarMaybeUndef < Tag , Id > {
563
567
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
564
568
match self {
565
- ScalarMaybeUndef :: Undef => write ! ( f, "Undef " ) ,
569
+ ScalarMaybeUndef :: Undef => write ! ( f, "<uninitialized> " ) ,
566
570
ScalarMaybeUndef :: Scalar ( s) => write ! ( f, "{:?}" , s) ,
567
571
}
568
572
}
569
573
}
570
574
571
- impl < Tag > fmt:: Display for ScalarMaybeUndef < Tag > {
575
+ impl < Tag : fmt :: Debug > fmt:: Display for ScalarMaybeUndef < Tag > {
572
576
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
573
577
match self {
574
578
ScalarMaybeUndef :: Undef => write ! ( f, "uninitialized bytes" ) ,
0 commit comments