Skip to content

Commit 4129463

Browse files
authored
Rollup merge of #61979 - spastorino:fmt-place-base, r=oli-obk
Implement Debug for PlaceBase r? @oli-obk More tiny bits that can be extracted from Place 2.0 PR
2 parents d3898a6 + f0d9d55 commit 4129463

File tree

1 file changed

+25
-23
lines changed

1 file changed

+25
-23
lines changed

src/librustc/mir/mod.rs

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2184,29 +2184,7 @@ impl<'tcx> Debug for Place<'tcx> {
21842184
});
21852185

21862186
self.iterate(|place_base, place_projections| {
2187-
match place_base {
2188-
PlaceBase::Local(id) => {
2189-
write!(fmt, "{:?}", id)?;
2190-
}
2191-
PlaceBase::Static(box self::Static { ty, kind: StaticKind::Static(def_id) }) => {
2192-
write!(
2193-
fmt,
2194-
"({}: {:?})",
2195-
ty::tls::with(|tcx| tcx.def_path_str(*def_id)),
2196-
ty
2197-
)?;
2198-
},
2199-
PlaceBase::Static(
2200-
box self::Static { ty, kind: StaticKind::Promoted(promoted) }
2201-
) => {
2202-
write!(
2203-
fmt,
2204-
"({:?}: {:?})",
2205-
promoted,
2206-
ty
2207-
)?;
2208-
},
2209-
}
2187+
write!(fmt, "{:?}", place_base)?;
22102188

22112189
for projection in place_projections {
22122190
match projection.elem {
@@ -2256,6 +2234,30 @@ impl<'tcx> Debug for Place<'tcx> {
22562234
}
22572235
}
22582236

2237+
impl Debug for PlaceBase<'_> {
2238+
fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result {
2239+
match *self {
2240+
PlaceBase::Local(id) => write!(fmt, "{:?}", id),
2241+
PlaceBase::Static(box self::Static { ty, kind: StaticKind::Static(def_id) }) => {
2242+
write!(
2243+
fmt,
2244+
"({}: {:?})",
2245+
ty::tls::with(|tcx| tcx.def_path_str(def_id)),
2246+
ty
2247+
)
2248+
},
2249+
PlaceBase::Static(box self::Static { ty, kind: StaticKind::Promoted(promoted) }) => {
2250+
write!(
2251+
fmt,
2252+
"({:?}: {:?})",
2253+
promoted,
2254+
ty
2255+
)
2256+
},
2257+
}
2258+
}
2259+
}
2260+
22592261
///////////////////////////////////////////////////////////////////////////
22602262
// Scopes
22612263

0 commit comments

Comments
 (0)