refactor unsafety checking of places

This commit is contained in:
Ralf Jung 2020-11-21 13:20:34 +01:00
parent df1c55a474
commit 571da2c62d
2 changed files with 87 additions and 76 deletions

View file

@ -1744,7 +1744,9 @@ impl<'tcx> Place<'tcx> {
/// Iterate over the projections in evaluation order, i.e., the first element is the base with
/// its projection and then subsequently more projections are added.
pub fn iter_projections(self) -> impl Iterator<Item=(PlaceRef<'tcx>, PlaceElem<'tcx>)> + DoubleEndedIterator {
pub fn iter_projections(
self,
) -> impl Iterator<Item = (PlaceRef<'tcx>, PlaceElem<'tcx>)> + DoubleEndedIterator {
self.projection.iter().enumerate().map(move |(i, proj)| {
let base = PlaceRef { local: self.local, projection: &self.projection[..i] };
(base, proj)