Skip to content

Commit 50eb5f6

Browse files
committed
Explain the math
1 parent 3e7a4ca commit 50eb5f6

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/librustc_mir/interpret/memory.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -707,10 +707,15 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
707707
new_relocations.extend(
708708
relocations
709709
.iter()
710-
.map(|&(offset, reloc)| (
711-
offset + dest.offset - src.offset + (i * size),
712-
reloc,
713-
))
710+
.map(|&(offset, reloc)| {
711+
// compute offset for current repetition
712+
let dest_offset = dest.offset + (i * size);
713+
(
714+
// shift offsets from source allocation to destination allocation
715+
offset + dest_offset - src.offset,
716+
reloc,
717+
)
718+
})
714719
);
715720
}
716721

0 commit comments

Comments
 (0)