diff options
| author | Austin Hicks <camlorn@camlorn.net> | 2016-11-20 13:14:13 -0500 |
|---|---|---|
| committer | Austin Hicks <camlorn@camlorn.net> | 2016-12-14 12:28:19 -0500 |
| commit | d75477808307ca1c0e0384f300404b94565b7ac4 (patch) | |
| tree | c1a465fa1c45699e402748512fd0ff6b52587dfe | |
| parent | 27469037d7dabe602e0f528dbb9791c44cc236b0 (diff) | |
| download | rust-d75477808307ca1c0e0384f300404b94565b7ac4.tar.gz rust-d75477808307ca1c0e0384f300404b94565b7ac4.zip | |
Fix tuple and closure literals.
| -rw-r--r-- | src/librustc_trans/mir/operand.rs | 2 | ||||
| -rw-r--r-- | src/librustc_trans/mir/rvalue.rs | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/src/librustc_trans/mir/operand.rs b/src/librustc_trans/mir/operand.rs index 62eda56e2e1..83e1d03c689 100644 --- a/src/librustc_trans/mir/operand.rs +++ b/src/librustc_trans/mir/operand.rs @@ -246,7 +246,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> { lldest: ValueRef, operand: OperandRef<'tcx>) { - debug!("store_operand: operand={:?}", operand); + debug!("store_operand: operand={:?} lldest={:?}", operand, lldest); bcx.with_block(|bcx| self.store_operand_direct(bcx, lldest, operand)) } diff --git a/src/librustc_trans/mir/rvalue.rs b/src/librustc_trans/mir/rvalue.rs index 15cbbc720d6..a89c61cd36a 100644 --- a/src/librustc_trans/mir/rvalue.rs +++ b/src/librustc_trans/mir/rvalue.rs @@ -133,6 +133,13 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> { } }, _ => { + // If this is a tuple or closure, we need to translate GEP indices. + let layout = bcx.ccx().layout_of(dest.ty.to_ty(bcx.tcx())); + let translation = if let Layout::Univariant { ref variant, .. } = *layout { + Some(&variant.gep_index) + } else { + None + }; for (i, operand) in operands.iter().enumerate() { let op = self.trans_operand(&bcx, operand); // Do not generate stores and GEPis for zero-sized fields. @@ -140,6 +147,11 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> { // Note: perhaps this should be StructGep, but // note that in some cases the values here will // not be structs but arrays. + let i = if let Some(ref t) = translation { + t[i] as usize + } else { + i + }; let dest = bcx.gepi(dest.llval, &[0, i]); self.store_operand(&bcx, dest, op); } |
