Skip to content

Commit 3dccf83

Browse files
committed
Make eval_place_to_op iterate instead of recurse
1 parent 27cc0db commit 3dccf83

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/librustc_mir/interpret/operand.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -467,22 +467,22 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> InterpretCx<'a, 'mir, 'tcx, M>
467467
mir_place: &mir::Place<'tcx>,
468468
layout: Option<TyLayout<'tcx>>,
469469
) -> EvalResult<'tcx, OpTy<'tcx, M::PointerTag>> {
470-
use rustc::mir::Place::*;
471470
use rustc::mir::PlaceBase;
472-
let op = match *mir_place {
473-
Base(PlaceBase::Local(mir::RETURN_PLACE)) => return err!(ReadFromReturnPointer),
474-
Base(PlaceBase::Local(local)) => self.access_local(self.frame(), local, layout)?,
475471

476-
Projection(ref proj) => {
477-
let op = self.eval_place_to_op(&proj.base, None)?;
478-
self.operand_projection(op, &proj.elem)?
479-
}
472+
mir_place.iterate(|place_base, place_projection| {
473+
let mut op = match place_base {
474+
PlaceBase::Local(mir::RETURN_PLACE) => return err!(ReadFromReturnPointer),
475+
PlaceBase::Local(local) => self.access_local(self.frame(), *local, layout)?,
476+
_ => self.eval_place_to_mplace(mir_place)?.into(),
477+
};
480478

481-
_ => self.eval_place_to_mplace(mir_place)?.into(),
482-
};
479+
for proj in place_projection {
480+
op = self.operand_projection(op, &proj.elem)?
481+
}
483482

484-
trace!("eval_place_to_op: got {:?}", *op);
485-
Ok(op)
483+
trace!("eval_place_to_op: got {:?}", op);
484+
Ok(op)
485+
})
486486
}
487487

488488
/// Evaluate the operand, returning a place where you can then find the data.

0 commit comments

Comments
 (0)