Explain the math

This commit is contained in:
Oliver Scherer 2018-12-18 10:08:37 +01:00
parent 3e7a4ca2f1
commit 50eb5f6137

View File

@ -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,
)
})
);
}