Skip to content

Commit

Permalink
Rollup merge of rust-lang#61979 - spastorino:fmt-place-base, r=oli-obk
Browse files Browse the repository at this point in the history
Implement Debug for PlaceBase

r? @oli-obk

More tiny bits that can be extracted from Place 2.0 PR
  • Loading branch information
Centril committed Jun 20, 2019
2 parents d3898a6 + f0d9d55 commit 4129463
Showing 1 changed file with 25 additions and 23 deletions.
48 changes: 25 additions & 23 deletions src/librustc/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2184,29 +2184,7 @@ impl<'tcx> Debug for Place<'tcx> {
});

self.iterate(|place_base, place_projections| {
match place_base {
PlaceBase::Local(id) => {
write!(fmt, "{:?}", id)?;
}
PlaceBase::Static(box self::Static { ty, kind: StaticKind::Static(def_id) }) => {
write!(
fmt,
"({}: {:?})",
ty::tls::with(|tcx| tcx.def_path_str(*def_id)),
ty
)?;
},
PlaceBase::Static(
box self::Static { ty, kind: StaticKind::Promoted(promoted) }
) => {
write!(
fmt,
"({:?}: {:?})",
promoted,
ty
)?;
},
}
write!(fmt, "{:?}", place_base)?;

for projection in place_projections {
match projection.elem {
Expand Down Expand Up @@ -2256,6 +2234,30 @@ impl<'tcx> Debug for Place<'tcx> {
}
}

impl Debug for PlaceBase<'_> {
fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result {
match *self {
PlaceBase::Local(id) => write!(fmt, "{:?}", id),
PlaceBase::Static(box self::Static { ty, kind: StaticKind::Static(def_id) }) => {
write!(
fmt,
"({}: {:?})",
ty::tls::with(|tcx| tcx.def_path_str(def_id)),
ty
)
},
PlaceBase::Static(box self::Static { ty, kind: StaticKind::Promoted(promoted) }) => {
write!(
fmt,
"({:?}: {:?})",
promoted,
ty
)
},
}
}
}

///////////////////////////////////////////////////////////////////////////
// Scopes

Expand Down

0 comments on commit 4129463

Please sign in to comment.