Skip to content

Commit 54d4e26

Browse files
committed
Rollup merge of rust-lang#56919 - oli-obk:null_ref_array_tuple, r=RalfJung
Remove a wrong multiplier on relocation offset computation r? @RalfJung fixes rust-lang#56800
2 parents beaf071 + 50eb5f6 commit 54d4e26

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/librustc_mir/interpret/memory.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -708,8 +708,13 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
708708
relocations
709709
.iter()
710710
.map(|&(offset, reloc)| {
711-
(offset + dest.offset - src.offset + (i * size * relocations.len() as u64),
712-
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+
)
713718
})
714719
);
715720
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// compile-pass
2+
3+
fn main() {
4+
let _ = &[("", ""); 3];
5+
}
6+
7+
const FOO: &[(&str, &str)] = &[("", ""); 3];
8+
const BAR: &[(&str, &str); 5] = &[("", ""); 5];
9+
const BAA: &[[&str; 12]; 11] = &[[""; 12]; 11];

0 commit comments

Comments
 (0)