Skip to content

Commit b6d9f83

Browse files
committed
trans: use Pair for ignored nil pairs instead of Immediate.
1 parent 8cbffc5 commit b6d9f83

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/librustc_trans/mir/mod.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,12 @@ impl<'tcx> TempRef<'tcx> {
124124
// Zero-size temporaries aren't always initialized, which
125125
// doesn't matter because they don't contain data, but
126126
// we need something in the operand.
127-
let val = OperandValue::Immediate(common::C_nil(ccx));
127+
let nil = common::C_nil(ccx);
128+
let val = if common::type_is_imm_pair(ccx, ty) {
129+
OperandValue::Pair(nil, nil)
130+
} else {
131+
OperandValue::Immediate(nil)
132+
};
128133
let op = OperandRef {
129134
val: val,
130135
ty: ty

src/test/run-pass/mir_trans_calls.rs

+12
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,16 @@ fn test_fn_transmute_zst(x: ()) -> [(); 1] {
147147
})
148148
}
149149

150+
#[rustc_mir]
151+
fn test_fn_ignored_pair() -> ((), ()) {
152+
((), ())
153+
}
154+
155+
#[rustc_mir]
156+
fn test_fn_ignored_pair_0() {
157+
test_fn_ignored_pair().0
158+
}
159+
150160
fn main() {
151161
assert_eq!(test1(1, (2, 3), &[4, 5, 6]), (1, (2, 3), &[4, 5, 6][..]));
152162
assert_eq!(test2(98), 98);
@@ -169,4 +179,6 @@ fn main() {
169179

170180
assert_eq!(test_fn_nil_call(&(|| 42)), 42);
171181
assert_eq!(test_fn_transmute_zst(()), [()]);
182+
183+
assert_eq!(test_fn_ignored_pair_0(), ());
172184
}

0 commit comments

Comments
 (0)