about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustc_trans/trans/mir/operand.rs19
1 files changed, 5 insertions, 14 deletions
diff --git a/src/librustc_trans/trans/mir/operand.rs b/src/librustc_trans/trans/mir/operand.rs
index a0308032ac0..fb529d8975e 100644
--- a/src/librustc_trans/trans/mir/operand.rs
+++ b/src/librustc_trans/trans/mir/operand.rs
@@ -92,19 +92,10 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
                bcx.val_to_string(lldest),
                operand);
 
-        match *operand {
-            mir::Operand::Consume(ref lvalue) => {
-                let tr_lvalue = self.trans_lvalue(bcx, lvalue);
-                let lvalue_ty = tr_lvalue.ty.to_ty(bcx.tcx());
-                debug!("trans_operand_into: tr_lvalue={} @ {:?}",
-                       bcx.val_to_string(tr_lvalue.llval),
-                       lvalue_ty);
-                base::memcpy_ty(bcx, lldest, tr_lvalue.llval, lvalue_ty);
-            }
-
-            mir::Operand::Constant(..) => {
-                unimplemented!()
-            }
-        }
+        let o = self.trans_operand(bcx, operand);
+        match datum::appropriate_rvalue_mode(bcx.ccx(), o.ty) {
+            datum::ByValue => base::store_ty(bcx, o.llval, lldest, o.ty),
+            datum::ByRef => base::memcpy_ty(bcx, lldest, o.llval, o.ty),
+        };
     }
 }