Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/librustc_mir/interpret/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -707,10 +707,10 @@ 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 * relocations.len() as u64),
reloc)
})
.map(|&(offset, reloc)| (
offset + dest.offset - src.offset + (i * size),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be clearer to do something like let dest_offset = dest.offset + (i * size); and then offset + dest_offset - src.offset to show that the i * size is part of the destination offset (I started at this for a bit wondering where it is coming from).

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];