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

Rollup of 4 pull requests #61962

Merged
merged 8 commits into from
Jun 19, 2019
Next Next commit
Make Place::ty iterate
  • Loading branch information
spastorino committed Jun 18, 2019
commit f4737d5607eabbfc07440b0ce64b852395948a68
26 changes: 19 additions & 7 deletions src/librustc/mir/tcx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,25 @@ impl<'tcx> Place<'tcx> {
where
D: HasLocalDecls<'tcx>,
{
match *self {
Place::Base(PlaceBase::Local(index)) =>
PlaceTy::from_ty(local_decls.local_decls()[index].ty),
Place::Base(PlaceBase::Static(ref data)) =>
PlaceTy::from_ty(data.ty),
Place::Projection(ref proj) =>
proj.base.ty(local_decls, tcx).projection_ty(tcx, &proj.elem),
self.iterate(|place_base, place_projections| {
let mut place_ty = place_base.ty(local_decls);

for proj in place_projections {
place_ty = place_ty.projection_ty(tcx, &proj.elem);
}

place_ty
})
}
}

impl<'tcx> PlaceBase<'tcx> {
pub fn ty<D>(&self, local_decls: &D) -> PlaceTy<'tcx>
where D: HasLocalDecls<'tcx>
{
match self {
PlaceBase::Local(index) => PlaceTy::from_ty(local_decls.local_decls()[*index].ty),
PlaceBase::Static(data) => PlaceTy::from_ty(data.ty),
}
}
}
Expand Down