]> git.lizzy.rs Git - rust.git/commitdiff
trans: use Pair for ignored nil pairs instead of Immediate.
authorEduard Burtescu <edy.burt@gmail.com>
Mon, 6 Jun 2016 21:24:21 +0000 (00:24 +0300)
committerEduard Burtescu <edy.burt@gmail.com>
Mon, 6 Jun 2016 21:24:21 +0000 (00:24 +0300)
src/librustc_trans/mir/mod.rs
src/test/run-pass/mir_trans_calls.rs

index d1206550b13d6bb705acb99000522a914da3b4ce..408b30c72582cd398acd6baae0a2c12cbef86a86 100644 (file)
@@ -124,7 +124,12 @@ fn new_operand<'bcx>(ccx: &CrateContext<'bcx, 'tcx>,
             // Zero-size temporaries aren't always initialized, which
             // doesn't matter because they don't contain data, but
             // we need something in the operand.
-            let val = OperandValue::Immediate(common::C_nil(ccx));
+            let nil = common::C_nil(ccx);
+            let val = if common::type_is_imm_pair(ccx, ty) {
+                OperandValue::Pair(nil, nil)
+            } else {
+                OperandValue::Immediate(nil)
+            };
             let op = OperandRef {
                 val: val,
                 ty: ty
index 31e2c8925711cc28959bda1a13351178f03ceb14..0527f38a9c36dfbc3fa96b8452eba33791a05baf 100644 (file)
@@ -147,6 +147,16 @@ fn id<T>(x: T) -> T {x}
     })
 }
 
+#[rustc_mir]
+fn test_fn_ignored_pair() -> ((), ()) {
+    ((), ())
+}
+
+#[rustc_mir]
+fn test_fn_ignored_pair_0() {
+    test_fn_ignored_pair().0
+}
+
 fn main() {
     assert_eq!(test1(1, (2, 3), &[4, 5, 6]), (1, (2, 3), &[4, 5, 6][..]));
     assert_eq!(test2(98), 98);
@@ -169,4 +179,6 @@ fn main() {
 
     assert_eq!(test_fn_nil_call(&(|| 42)), 42);
     assert_eq!(test_fn_transmute_zst(()), [()]);
+
+    assert_eq!(test_fn_ignored_pair_0(), ());
 }