Skip to content

Commit e0e8e00

Browse files
author
Ellen Arteca
committed
no more direct hole punch to alloc bytes
1 parent fde4235 commit e0e8e00

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

compiler/rustc_middle/src/mir/interpret/allocation.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use crate::ty;
3333
pub struct Allocation<Prov = AllocId, Extra = ()> {
3434
/// The actual bytes of the allocation.
3535
/// Note that the bytes of a pointer represent the offset of the pointer.
36-
pub bytes: Box<[u8]>,
36+
bytes: Box<[u8]>,
3737
/// Maps from byte addresses to extra data for each pointer.
3838
/// Only the first byte of a pointer is inserted into the map; i.e.,
3939
/// every entry in this map applies to `pointer_size` consecutive bytes starting
@@ -352,6 +352,11 @@ impl<Prov, Extra> Allocation<Prov, Extra> {
352352

353353
/// Byte accessors.
354354
impl<Prov: Provenance, Extra> Allocation<Prov, Extra> {
355+
/// Get the pointer of the [u8] of bytes.
356+
pub fn get_bytes_addr(&self) -> Size {
357+
Size::from_bytes(self.bytes.as_ptr() as u64)
358+
}
359+
355360
/// This is the entirely abstraction-violating way to just grab the raw bytes without
356361
/// caring about relocations. It just deduplicates some code between `read_scalar`
357362
/// and `get_bytes_internal`.

0 commit comments

Comments
 (0)