Skip to content

Commit fb5b268

Browse files
committed
Pull out a statement that all match arms are executing
1 parent 4bff385 commit fb5b268

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/librustc_mir/interpret/eval_context.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -771,16 +771,15 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M
771771
Cast(kind, ref operand, cast_ty) => {
772772
debug_assert_eq!(self.monomorphize(cast_ty, self.substs()), dest_ty);
773773
use rustc::mir::CastKind::*;
774+
let src = self.eval_operand(operand)?;
774775
match kind {
775776
Unsize => {
776-
let src = self.eval_operand(operand)?;
777777
let src_layout = self.layout_of(src.ty)?;
778778
let dst_layout = self.layout_of(dest_ty)?;
779779
self.unsize_into(src.value, src_layout, dest, dst_layout)?;
780780
}
781781

782782
Misc => {
783-
let src = self.eval_operand(operand)?;
784783
if self.type_is_fat_ptr(src.ty) {
785784
match (src.value, self.type_is_fat_ptr(dest_ty)) {
786785
(Value::ByRef { .. }, _) |
@@ -840,7 +839,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M
840839
}
841840

842841
ReifyFnPointer => {
843-
match self.eval_operand(operand)?.ty.sty {
842+
match src.ty.sty {
844843
ty::TyFnDef(def_id, substs) => {
845844
if self.tcx.has_attr(def_id, "rustc_args_required_const") {
846845
bug!("reifying a fn ptr that requires \
@@ -866,7 +865,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M
866865
UnsafeFnPointer => {
867866
match dest_ty.sty {
868867
ty::TyFnPtr(_) => {
869-
let mut src = self.eval_operand(operand)?;
868+
let mut src = src;
870869
src.ty = dest_ty;
871870
self.write_value(src, dest)?;
872871
}
@@ -875,7 +874,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M
875874
}
876875

877876
ClosureFnPointer => {
878-
match self.eval_operand(operand)?.ty.sty {
877+
match src.ty.sty {
879878
ty::TyClosure(def_id, substs) => {
880879
let substs = self.tcx.subst_and_normalize_erasing_regions(
881880
self.substs(),

0 commit comments

Comments
 (0)