Skip to content

Commit

Permalink
Explain the math
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Dec 18, 2018
1 parent 3e7a4ca commit 50eb5f6
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/librustc_mir/interpret/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -707,10 +707,15 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
new_relocations.extend(
relocations
.iter()
.map(|&(offset, reloc)| (
offset + dest.offset - src.offset + (i * size),
reloc,
))
.map(|&(offset, 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

0 comments on commit 50eb5f6

Please sign in to comment.