Skip to content

Commit 82927cf

Browse files
authored
Rollup merge of #64473 - spastorino:use-try-fold, r=Centril
Use try_fold instead of manually carrying an accumulator r? @RalfJung
2 parents 3e4c778 + 8ee77a2 commit 82927cf

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/librustc_mir/interpret/operand.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
477477
) -> InterpResult<'tcx, OpTy<'tcx, M::PointerTag>> {
478478
use rustc::mir::PlaceBase;
479479

480-
let mut op = match &place.base {
480+
let base_op = match &place.base {
481481
PlaceBase::Local(mir::RETURN_PLACE) =>
482482
throw_unsup!(ReadFromReturnPointer),
483483
PlaceBase::Local(local) => {
@@ -497,9 +497,10 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
497497
}
498498
};
499499

500-
for elem in place.projection.iter() {
501-
op = self.operand_projection(op, elem)?
502-
}
500+
let op = place.projection.iter().try_fold(
501+
base_op,
502+
|op, elem| self.operand_projection(op, elem)
503+
)?;
503504

504505
trace!("eval_place_to_op: got {:?}", *op);
505506
Ok(op)

0 commit comments

Comments
 (0)