Skip to content

Commit bf6c505

Browse files
authored
Rollup merge of #61940 - spastorino:place-ty-iterate, r=oli-obk
Make Place::ty iterate r? @oli-obk Related to Place 2.0
2 parents d88b7b2 + f4737d5 commit bf6c505

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

src/librustc/mir/tcx.rs

+19-7
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,25 @@ impl<'tcx> Place<'tcx> {
122122
where
123123
D: HasLocalDecls<'tcx>,
124124
{
125-
match *self {
126-
Place::Base(PlaceBase::Local(index)) =>
127-
PlaceTy::from_ty(local_decls.local_decls()[index].ty),
128-
Place::Base(PlaceBase::Static(ref data)) =>
129-
PlaceTy::from_ty(data.ty),
130-
Place::Projection(ref proj) =>
131-
proj.base.ty(local_decls, tcx).projection_ty(tcx, &proj.elem),
125+
self.iterate(|place_base, place_projections| {
126+
let mut place_ty = place_base.ty(local_decls);
127+
128+
for proj in place_projections {
129+
place_ty = place_ty.projection_ty(tcx, &proj.elem);
130+
}
131+
132+
place_ty
133+
})
134+
}
135+
}
136+
137+
impl<'tcx> PlaceBase<'tcx> {
138+
pub fn ty<D>(&self, local_decls: &D) -> PlaceTy<'tcx>
139+
where D: HasLocalDecls<'tcx>
140+
{
141+
match self {
142+
PlaceBase::Local(index) => PlaceTy::from_ty(local_decls.local_decls()[*index].ty),
143+
PlaceBase::Static(data) => PlaceTy::from_ty(data.ty),
132144
}
133145
}
134146
}

0 commit comments

Comments
 (0)