Skip to content

Commit bd18cc5

Browse files
committed
Remove an intermediate value from discriminant reading
1 parent 235a6b7 commit bd18cc5

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/librustc_mir/interpret/operand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
508508

509509
// Evaluate a place with the goal of reading from it. This lets us sometimes
510510
// avoid allocations.
511-
fn eval_place_to_op(
511+
pub(super) fn eval_place_to_op(
512512
&self,
513513
mir_place: &mir::Place<'tcx>,
514514
layout: Option<TyLayout<'tcx>>,

src/librustc_mir/interpret/step.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,8 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
266266
}
267267

268268
Discriminant(ref place) => {
269-
let place = self.eval_place(place)?;
270-
let discr_val = self.read_discriminant(self.place_to_op(place)?)?.0;
269+
let op = self.eval_place_to_op(place, None)?;
270+
let discr_val = self.read_discriminant(op)?.0;
271271
let size = dest.layout.size;
272272
self.write_scalar(Scalar::from_uint(discr_val, size), dest)?;
273273
}

0 commit comments

Comments
 (0)