Skip to content

Commit

Permalink
Refactor const_to_op
Browse files Browse the repository at this point in the history
  • Loading branch information
varkor committed Mar 6, 2019
1 parent ed9227a commit de4478a
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/librustc_mir/interpret/operand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -589,17 +589,12 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
val: ty::Const<'tcx>,
layout: Option<TyLayout<'tcx>>,
) -> EvalResult<'tcx, OpTy<'tcx, M::PointerTag>> {
let val = self.monomorphize(val)?;
let layout = from_known_layout(layout, || {
let ty = self.monomorphize(val.ty)?;
self.layout_of(ty)
self.layout_of(val.ty)
})?;
let val = match val.val {
ConstValue::Param(_) => self.monomorphize(val)?.val,
ConstValue::Infer(_) => bug!(),
val => val,
};
let op = match val {
ConstValue::Param(_) | ConstValue::Infer(_) => unreachable!(),
let op = match val.val {
ConstValue::Param(_) | ConstValue::Infer(_) => bug!(),
ConstValue::ByRef(ptr, alloc) => {
// We rely on mutability being set correctly in that allocation to prevent writes
// where none should happen -- and for `static mut`, we copy on demand anyway.
Expand Down

0 comments on commit de4478a

Please sign in to comment.