Skip to content

Commit

Permalink
make interpreter type Debug impl independent of Ty debug impl
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Sep 15, 2023
1 parent 9cbc90c commit 06a76ab
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
12 changes: 10 additions & 2 deletions compiler/rustc_const_eval/src/interpret/operand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,11 @@ impl<Prov: Provenance> std::fmt::Display for ImmTy<'_, Prov> {

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

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

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

Expand Down
9 changes: 7 additions & 2 deletions compiler/rustc_const_eval/src/interpret/place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,10 @@ pub struct MPlaceTy<'tcx, Prov: Provenance = AllocId> {

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

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

Expand Down

0 comments on commit 06a76ab

Please sign in to comment.