Skip to content

Commit 4894123

Browse files
committed
Auto merge of #64211 - oli-obk:miri, r=eddyb
Fix miri fixes #64109 cc @HeroicKatora cc @RalfJung
2 parents 1fb3c4e + 39bfb36 commit 4894123

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

src/librustc/mir/interpret/allocation.rs

+28
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,34 @@ impl<Tag> Allocation<Tag> {
130130
}
131131
}
132132

133+
impl Allocation<()> {
134+
/// Add Tag and Extra fields
135+
pub fn retag<T, E>(
136+
self,
137+
mut tagger: impl FnMut(AllocId) -> T,
138+
extra: E,
139+
) -> Allocation<T, E> {
140+
Allocation {
141+
bytes: self.bytes,
142+
size: self.size,
143+
relocations: Relocations::from_presorted(
144+
self.relocations.iter()
145+
// The allocations in the relocations (pointers stored *inside* this allocation)
146+
// all get the base pointer tag.
147+
.map(|&(offset, ((), alloc))| {
148+
let tag = tagger(alloc);
149+
(offset, (tag, alloc))
150+
})
151+
.collect()
152+
),
153+
undef_mask: self.undef_mask,
154+
align: self.align,
155+
mutability: self.mutability,
156+
extra,
157+
}
158+
}
159+
}
160+
133161
/// Raw accessors. Provide access to otherwise private bytes.
134162
impl<Tag, Extra> Allocation<Tag, Extra> {
135163
pub fn len(&self) -> usize {

0 commit comments

Comments
 (0)