mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-05 19:58:32 +00:00
Remove an intermediate value from discriminant reading
This commit is contained in:
parent
235a6b7d06
commit
bd18cc5708
@ -508,7 +508,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
|
|||||||
|
|
||||||
// Evaluate a place with the goal of reading from it. This lets us sometimes
|
// Evaluate a place with the goal of reading from it. This lets us sometimes
|
||||||
// avoid allocations.
|
// avoid allocations.
|
||||||
fn eval_place_to_op(
|
pub(super) fn eval_place_to_op(
|
||||||
&self,
|
&self,
|
||||||
mir_place: &mir::Place<'tcx>,
|
mir_place: &mir::Place<'tcx>,
|
||||||
layout: Option<TyLayout<'tcx>>,
|
layout: Option<TyLayout<'tcx>>,
|
||||||
|
@ -266,8 +266,8 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
|
|||||||
}
|
}
|
||||||
|
|
||||||
Discriminant(ref place) => {
|
Discriminant(ref place) => {
|
||||||
let place = self.eval_place(place)?;
|
let op = self.eval_place_to_op(place, None)?;
|
||||||
let discr_val = self.read_discriminant(self.place_to_op(place)?)?.0;
|
let discr_val = self.read_discriminant(op)?.0;
|
||||||
let size = dest.layout.size;
|
let size = dest.layout.size;
|
||||||
self.write_scalar(Scalar::from_uint(discr_val, size), dest)?;
|
self.write_scalar(Scalar::from_uint(discr_val, size), dest)?;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user