Skip to content

Commit 06a76ab

Browse files
committed
make interpreter type Debug impl independent of Ty debug impl
1 parent 9cbc90c commit 06a76ab

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

compiler/rustc_const_eval/src/interpret/operand.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,11 @@ impl<Prov: Provenance> std::fmt::Display for ImmTy<'_, Prov> {
136136

137137
impl<Prov: Provenance> std::fmt::Debug for ImmTy<'_, Prov> {
138138
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
139-
f.debug_struct("ImmTy").field("imm", &self.imm).field("ty", &self.layout.ty).finish()
139+
// Printing `layout` results in too much noise; just print a nice version of the type.
140+
f.debug_struct("ImmTy")
141+
.field("imm", &self.imm)
142+
.field("ty", &format_args!("{}", self.layout.ty))
143+
.finish()
140144
}
141145
}
142146

@@ -305,7 +309,11 @@ pub struct OpTy<'tcx, Prov: Provenance = AllocId> {
305309

306310
impl<Prov: Provenance> std::fmt::Debug for OpTy<'_, Prov> {
307311
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
308-
f.debug_struct("OpTy").field("op", &self.op).field("ty", &self.layout.ty).finish()
312+
// Printing `layout` results in too much noise; just print a nice version of the type.
313+
f.debug_struct("OpTy")
314+
.field("op", &self.op)
315+
.field("ty", &format_args!("{}", self.layout.ty))
316+
.finish()
309317
}
310318
}
311319

compiler/rustc_const_eval/src/interpret/place.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,10 @@ pub struct MPlaceTy<'tcx, Prov: Provenance = AllocId> {
117117

118118
impl<Prov: Provenance> std::fmt::Debug for MPlaceTy<'_, Prov> {
119119
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
120+
// Printing `layout` results in too much noise; just print a nice version of the type.
120121
f.debug_struct("MPlaceTy")
121122
.field("mplace", &self.mplace)
122-
.field("ty", &self.layout.ty)
123+
.field("ty", &format_args!("{}", self.layout.ty))
123124
.finish()
124125
}
125126
}
@@ -237,7 +238,11 @@ pub struct PlaceTy<'tcx, Prov: Provenance = AllocId> {
237238

238239
impl<Prov: Provenance> std::fmt::Debug for PlaceTy<'_, Prov> {
239240
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
240-
f.debug_struct("PlaceTy").field("place", &self.place).field("ty", &self.layout.ty).finish()
241+
// Printing `layout` results in too much noise; just print a nice version of the type.
242+
f.debug_struct("PlaceTy")
243+
.field("place", &self.place)
244+
.field("ty", &format_args!("{}", self.layout.ty))
245+
.finish()
241246
}
242247
}
243248

0 commit comments

Comments
 (0)