Skip to content

Commit

Permalink
Rollup merge of rust-lang#56919 - oli-obk:null_ref_array_tuple, r=Ral…
Browse files Browse the repository at this point in the history
…fJung

Remove a wrong multiplier on relocation offset computation

r? @RalfJung

fixes rust-lang#56800
  • Loading branch information
pietroalbini authored Dec 20, 2018
2 parents 5ecc80a + 50eb5f6 commit d96be3d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/librustc_mir/interpret/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -708,8 +708,13 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
relocations
.iter()
.map(|&(offset, reloc)| {
(offset + dest.offset - src.offset + (i * size * relocations.len() as u64),
reloc)
// compute offset for current repetition
let dest_offset = dest.offset + (i * size);
(
// shift offsets from source allocation to destination allocation
offset + dest_offset - src.offset,
reloc,
)
})
);
}
Expand Down
9 changes: 9 additions & 0 deletions src/test/ui/consts/promoted_regression.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// compile-pass

fn main() {
let _ = &[("", ""); 3];
}

const FOO: &[(&str, &str)] = &[("", ""); 3];
const BAR: &[(&str, &str); 5] = &[("", ""); 5];
const BAA: &[[&str; 12]; 11] = &[[""; 12]; 11];

0 comments on commit d96be3d

Please sign in to comment.