Skip to content

Commit de4478a

Browse files
committed
Refactor const_to_op
1 parent ed9227a commit de4478a

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

src/librustc_mir/interpret/operand.rs

+4-9
Original file line numberDiff line numberDiff line change
@@ -589,17 +589,12 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
589589
val: ty::Const<'tcx>,
590590
layout: Option<TyLayout<'tcx>>,
591591
) -> EvalResult<'tcx, OpTy<'tcx, M::PointerTag>> {
592+
let val = self.monomorphize(val)?;
592593
let layout = from_known_layout(layout, || {
593-
let ty = self.monomorphize(val.ty)?;
594-
self.layout_of(ty)
594+
self.layout_of(val.ty)
595595
})?;
596-
let val = match val.val {
597-
ConstValue::Param(_) => self.monomorphize(val)?.val,
598-
ConstValue::Infer(_) => bug!(),
599-
val => val,
600-
};
601-
let op = match val {
602-
ConstValue::Param(_) | ConstValue::Infer(_) => unreachable!(),
596+
let op = match val.val {
597+
ConstValue::Param(_) | ConstValue::Infer(_) => bug!(),
603598
ConstValue::ByRef(ptr, alloc) => {
604599
// We rely on mutability being set correctly in that allocation to prevent writes
605600
// where none should happen -- and for `static mut`, we copy on demand anyway.

0 commit comments

Comments
 (0)