Skip to content

Commit f8a9a1f

Browse files
csmoespastorino
authored andcommitted
add helper method ty_with_projections for base
1 parent 7b65fe8 commit f8a9a1f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/librustc/mir/tcx.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,21 @@ impl<'tcx> PlaceBase<'tcx> {
214214
PlaceBase::Static(data) => data.ty,
215215
}
216216
}
217+
218+
pub fn ty_with_projections(
219+
&self,
220+
local_decls: &impl HasLocalDecls<'tcx>,
221+
tcx: TyCtxt<'a, 'gcx, 'tcx>,
222+
elems: impl Iterator<Item = &'tcx PlaceElem<'tcx>>,
223+
) -> Ty<'tcx> {
224+
let mut base_ty = self.ty(local_decls);
225+
226+
for elem in elems {
227+
base_ty = PlaceTy::from(base_ty).projection_ty(tcx, elem).to_ty(tcx);
228+
}
229+
230+
base_ty
231+
}
217232
}
218233

219234
impl<'tcx> NeoPlace<'tcx> {

0 commit comments

Comments
 (0)