Rollup merge of #61120 - spastorino:eval-place-iterate, r=oli-obk
Make eval_place iterate instead of recurse r? @oli-obk
This commit is contained in:
commit
c3e1f99a69
@ -607,42 +607,42 @@ where
|
||||
/// place; for reading, a more efficient alternative is `eval_place_for_read`.
|
||||
pub fn eval_place(
|
||||
&mut self,
|
||||
mir_place: &mir::Place<'tcx>
|
||||
mir_place: &mir::Place<'tcx>,
|
||||
) -> EvalResult<'tcx, PlaceTy<'tcx, M::PointerTag>> {
|
||||
use rustc::mir::Place::*;
|
||||
use rustc::mir::PlaceBase;
|
||||
let place = match mir_place {
|
||||
Base(PlaceBase::Local(mir::RETURN_PLACE)) => match self.frame().return_place {
|
||||
Some(return_place) =>
|
||||
// We use our layout to verify our assumption; caller will validate
|
||||
// their layout on return.
|
||||
PlaceTy {
|
||||
place: *return_place,
|
||||
layout: self.layout_of(self.monomorphize(self.frame().mir.return_ty())?)?,
|
||||
},
|
||||
None => return err!(InvalidNullPointerUsage),
|
||||
},
|
||||
Base(PlaceBase::Local(local)) => PlaceTy {
|
||||
// This works even for dead/uninitialized locals; we check further when writing
|
||||
place: Place::Local {
|
||||
frame: self.cur_frame(),
|
||||
local: *local,
|
||||
|
||||
mir_place.iterate(|place_base, place_projection| {
|
||||
let mut place = match place_base {
|
||||
PlaceBase::Local(mir::RETURN_PLACE) => match self.frame().return_place {
|
||||
Some(return_place) => {
|
||||
// We use our layout to verify our assumption; caller will validate
|
||||
// their layout on return.
|
||||
PlaceTy {
|
||||
place: *return_place,
|
||||
layout: self
|
||||
.layout_of(self.monomorphize(self.frame().mir.return_ty())?)?,
|
||||
}
|
||||
}
|
||||
None => return err!(InvalidNullPointerUsage),
|
||||
},
|
||||
layout: self.layout_of_local(self.frame(), *local, None)?,
|
||||
},
|
||||
PlaceBase::Local(local) => PlaceTy {
|
||||
// This works even for dead/uninitialized locals; we check further when writing
|
||||
place: Place::Local {
|
||||
frame: self.cur_frame(),
|
||||
local: *local,
|
||||
},
|
||||
layout: self.layout_of_local(self.frame(), *local, None)?,
|
||||
},
|
||||
PlaceBase::Static(place_static) => self.eval_static_to_mplace(place_static)?.into(),
|
||||
};
|
||||
|
||||
Projection(proj) => {
|
||||
let place = self.eval_place(&proj.base)?;
|
||||
self.place_projection(place, &proj.elem)?
|
||||
for proj in place_projection {
|
||||
place = self.place_projection(place, &proj.elem)?
|
||||
}
|
||||
|
||||
Base(PlaceBase::Static(place_static)) => {
|
||||
self.eval_static_to_mplace(place_static)?.into()
|
||||
}
|
||||
};
|
||||
|
||||
self.dump_place(place.place);
|
||||
Ok(place)
|
||||
self.dump_place(place.place);
|
||||
Ok(place)
|
||||
})
|
||||
}
|
||||
|
||||
/// Write a scalar to a place
|
||||
|
Loading…
x
Reference in New Issue
Block a user