Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Debug for PlaceBase #61979

Merged
merged 1 commit into from
Jun 20, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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