about summary refs log tree commit diff
diff options
context:
space:
mode:
authorvarkor <github@varkor.com>2019-03-06 09:58:27 +0000
committervarkor <github@varkor.com>2019-03-06 09:58:27 +0000
commitde4478af91765999f51b2950bea16686ee4cd60a (patch)
tree140a26d5dd27f9cec68ddef6a41e3fade7d46bd7
parented9227abbdb14728777691c0d595a93c57a796bf (diff)
downloadrust-de4478af91765999f51b2950bea16686ee4cd60a.tar.gz
rust-de4478af91765999f51b2950bea16686ee4cd60a.zip
Refactor const_to_op
-rw-r--r--src/librustc_mir/interpret/operand.rs13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/librustc_mir/interpret/operand.rs b/src/librustc_mir/interpret/operand.rs
index 1ebff411510..206eaaf1787 100644
--- a/src/librustc_mir/interpret/operand.rs
+++ b/src/librustc_mir/interpret/operand.rs
@@ -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.