[][src]Struct rustc_mir::interpret::Allocation

pub struct Allocation<Tag = (), Extra = ()> {
    bytes: Vec<u8>,
    relocations: Relocations<Tag, AllocId>,
    init_mask: InitMask,
    pub size: Size,
    pub align: Align,
    pub mutability: Mutability,
    pub extra: Extra,
}
⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Fields

bytes: Vec<u8>
⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

The actual bytes of the allocation. Note that the bytes of a pointer represent the offset of the pointer.

relocations: Relocations<Tag, AllocId>
⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Maps from byte addresses to extra data for each pointer. Only the first byte of a pointer is inserted into the map; i.e., every entry in this map applies to pointer_size consecutive bytes starting at the given offset.

init_mask: InitMask
⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Denotes which part of this allocation is initialized.

size: Size
⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

The size of the allocation. Currently, must always equal bytes.len().

align: Align
⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

The alignment of the allocation to detect unaligned reads. (Align guarantees that this is a power of two.)

mutability: Mutability
⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

true if the allocation is mutable. Also used by codegen to determine if a static should be put into mutable memory, which happens for static mut and static with interior mutability.

extra: Extra
⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Extra state for the machine.

Implementations

impl<Tag> Allocation<Tag, ()>[src]

pub fn from_bytes<'a>(
    slice: impl Into<Cow<'a, [u8]>>,
    align: Align
) -> Allocation<Tag, ()>
[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Creates a read-only allocation initialized by the given bytes

pub fn from_byte_aligned_bytes<'a>(
    slice: impl Into<Cow<'a, [u8]>>
) -> Allocation<Tag, ()>
[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

pub fn undef(size: Size, align: Align) -> Allocation<Tag, ()>[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

impl Allocation<(), ()>[src]

pub fn with_tags_and_extra<T, E>(
    self,
    tagger: impl FnMut(AllocId) -> T,
    extra: E
) -> Allocation<T, E>
[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Add Tag and Extra fields

impl<Tag, Extra> Allocation<Tag, Extra>[src]

Raw accessors. Provide access to otherwise private bytes.

pub fn len(&self) -> usize[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

pub fn inspect_with_undef_and_ptr_outside_interpreter(
    &self,
    range: Range<usize>
) -> &[u8]
[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Looks at a slice which may describe undefined bytes or describe a relocation. This differs from get_bytes_with_undef_and_ptr in that it does no relocation checks (even on the edges) at all. It further ignores AllocationExtra callbacks. This must not be used for reads affecting the interpreter execution.

pub fn init_mask(&self) -> &InitMask[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Returns the mask indicating which bytes are initialized.

pub fn relocations(&self) -> &Relocations<Tag, AllocId>[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Returns the relocation list.

impl<'tcx, Tag, Extra> Allocation<Tag, Extra> where
    Extra: AllocationExtra<Tag>,
    Tag: Copy
[src]

Byte accessors.

pub fn get_bytes(
    &self,
    cx: &impl HasDataLayout,
    ptr: Pointer<Tag>,
    size: Size
) -> Result<&[u8], InterpErrorInfo<'tcx>>
[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Checks that these bytes are initialized and not pointer bytes, and then return them as a slice.

It is the caller's responsibility to check bounds and alignment beforehand. Most likely, you want to use the PlaceTy and OperandTy-based methods on InterpCx instead.

pub fn get_bytes_with_undef_and_ptr(
    &self,
    cx: &impl HasDataLayout,
    ptr: Pointer<Tag>,
    size: Size
) -> Result<&[u8], InterpErrorInfo<'tcx>>
[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

It is the caller's responsibility to handle undefined and pointer bytes. However, this still checks that there are no relocations on the edges.

It is the caller's responsibility to check bounds and alignment beforehand.

pub fn get_bytes_mut(
    &mut self,
    cx: &impl HasDataLayout,
    ptr: Pointer<Tag>,
    size: Size
) -> Result<&mut [u8], InterpErrorInfo<'tcx>>
[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Just calling this already marks everything as defined and removes relocations, so be sure to actually put data there!

It is the caller's responsibility to check bounds and alignment beforehand. Most likely, you want to use the PlaceTy and OperandTy-based methods on InterpCx instead.

impl<'tcx, Tag, Extra> Allocation<Tag, Extra> where
    Extra: AllocationExtra<Tag>,
    Tag: Copy
[src]

Reading and writing.

pub fn read_c_str(
    &self,
    cx: &impl HasDataLayout,
    ptr: Pointer<Tag>
) -> Result<&[u8], InterpErrorInfo<'tcx>>
[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Reads bytes until a 0 is encountered. Will error if the end of the allocation is reached before a 0 is found.

Most likely, you want to call Memory::read_c_str instead of this method.

pub fn check_bytes(
    &self,
    cx: &impl HasDataLayout,
    ptr: Pointer<Tag>,
    size: Size,
    allow_ptr_and_undef: bool
) -> Result<(), InterpErrorInfo<'tcx>>
[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Validates that ptr.offset and ptr.offset + size do not point to the middle of a relocation. If allow_ptr_and_undef is false, also enforces that the memory in the given range contains neither relocations nor undef bytes.

pub fn write_bytes(
    &mut self,
    cx: &impl HasDataLayout,
    ptr: Pointer<Tag>,
    src: impl IntoIterator<Item = u8>
) -> Result<(), InterpErrorInfo<'tcx>>
[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Writes src to the memory starting at ptr.offset.

It is the caller's responsibility to check bounds and alignment beforehand. Most likely, you want to call Memory::write_bytes instead of this method.

pub fn read_scalar(
    &self,
    cx: &impl HasDataLayout,
    ptr: Pointer<Tag>,
    size: Size
) -> Result<ScalarMaybeUninit<Tag>, InterpErrorInfo<'tcx>>
[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Reads a non-ZST scalar.

ZSTs can't be read for two reasons:

  • byte-order cannot work with zero-element buffers;
  • in order to obtain a Pointer, we need to check for ZSTness anyway due to integer pointers being valid for ZSTs.

It is the caller's responsibility to check bounds and alignment beforehand. Most likely, you want to call InterpCx::read_scalar instead of this method.

pub fn read_ptr_sized(
    &self,
    cx: &impl HasDataLayout,
    ptr: Pointer<Tag>
) -> Result<ScalarMaybeUninit<Tag>, InterpErrorInfo<'tcx>>
[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Reads a pointer-sized scalar.

It is the caller's responsibility to check bounds and alignment beforehand. Most likely, you want to call InterpCx::read_scalar instead of this method.

pub fn write_scalar(
    &mut self,
    cx: &impl HasDataLayout,
    ptr: Pointer<Tag>,
    val: ScalarMaybeUninit<Tag>,
    type_size: Size
) -> Result<(), InterpErrorInfo<'tcx>>
[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Writes a non-ZST scalar.

ZSTs can't be read for two reasons:

  • byte-order cannot work with zero-element buffers;
  • in order to obtain a Pointer, we need to check for ZSTness anyway due to integer pointers being valid for ZSTs.

It is the caller's responsibility to check bounds and alignment beforehand. Most likely, you want to call InterpCx::write_scalar instead of this method.

pub fn write_ptr_sized(
    &mut self,
    cx: &impl HasDataLayout,
    ptr: Pointer<Tag>,
    val: ScalarMaybeUninit<Tag>
) -> Result<(), InterpErrorInfo<'tcx>>
[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Writes a pointer-sized scalar.

It is the caller's responsibility to check bounds and alignment beforehand. Most likely, you want to call InterpCx::write_scalar instead of this method.

impl<'tcx, Tag, Extra> Allocation<Tag, Extra> where
    Tag: Copy
[src]

Relocations.

pub fn get_relocations(
    &self,
    cx: &impl HasDataLayout,
    ptr: Pointer<Tag>,
    size: Size
) -> &[(Size, (Tag, AllocId))]
[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Returns all relocations overlapping with the given pointer-offset pair.

impl<'tcx, Tag, Extra> Allocation<Tag, Extra> where
    Tag: Copy
[src]

Undefined bytes.

pub fn mark_definedness(
    &mut self,
    ptr: Pointer<Tag>,
    size: Size,
    new_state: bool
)
[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

impl<Tag, Extra> Allocation<Tag, Extra>[src]

Transferring the definedness mask to other allocations.

pub fn compress_undef_range(
    &self,
    src: Pointer<Tag>,
    size: Size
) -> AllocationDefinedness
[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Creates a run-length encoding of the undef mask.

pub fn mark_compressed_undef_range(
    &mut self,
    defined: &AllocationDefinedness,
    dest: Pointer<Tag>,
    size: Size,
    repeat: u64
)
[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Applies multiple instances of the run-length encoding to the undef mask.

impl<Tag, Extra> Allocation<Tag, Extra> where
    Tag: Copy
[src]

pub fn prepare_relocation_copy(
    &self,
    cx: &impl HasDataLayout,
    src: Pointer<Tag>,
    size: Size,
    dest: Pointer<Tag>,
    length: u64
) -> AllocationRelocations<Tag>
[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

pub fn mark_relocation_range(&mut self, relocations: AllocationRelocations<Tag>)[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Applies a relocation copy. The affected range, as defined in the parameters to prepare_relocation_copy is expected to be clear of relocations.

Trait Implementations

impl<'tcx> ArenaAllocatable<'tcx, Allocation<(), ()>> for Allocation<(), ()>[src]

impl<Tag, Extra> Clone for Allocation<Tag, Extra> where
    Extra: Clone,
    Tag: Clone
[src]

impl<Tag, Extra> Debug for Allocation<Tag, Extra> where
    Extra: Debug,
    Tag: Debug
[src]

impl<Tag, Extra> Decodable for Allocation<Tag, Extra> where
    Extra: Decodable,
    Tag: Decodable
[src]

impl<Tag, Extra> Encodable for Allocation<Tag, Extra> where
    Extra: Encodable,
    Tag: Encodable
[src]

impl<Tag, Extra> Eq for Allocation<Tag, Extra> where
    Extra: Eq,
    Tag: Eq
[src]

impl<Tag, Extra> Hash for Allocation<Tag, Extra> where
    Extra: Hash,
    Tag: Hash
[src]

impl<'__ctx, Tag, Extra> HashStable<StableHashingContext<'__ctx>> for Allocation<Tag, Extra> where
    Extra: HashStable<StableHashingContext<'__ctx>>,
    Tag: HashStable<StableHashingContext<'__ctx>>, 
[src]

impl<Tag, Extra> Ord for Allocation<Tag, Extra> where
    Extra: Ord,
    Tag: Ord
[src]

impl<Tag, Extra> PartialEq<Allocation<Tag, Extra>> for Allocation<Tag, Extra> where
    Extra: PartialEq<Extra>,
    Tag: PartialEq<Tag>, 
[src]

impl<Tag, Extra> PartialOrd<Allocation<Tag, Extra>> for Allocation<Tag, Extra> where
    Extra: PartialOrd<Extra>,
    Tag: PartialOrd<Tag>, 
[src]

impl<Tag, Extra> StructuralEq for Allocation<Tag, Extra>[src]

impl<Tag, Extra> StructuralPartialEq for Allocation<Tag, Extra>[src]

impl<'tcx> UseSpecializedDecodable for &'tcx Allocation<(), ()>[src]

Auto Trait Implementations

impl<Tag, Extra> RefUnwindSafe for Allocation<Tag, Extra> where
    Extra: RefUnwindSafe,
    Tag: RefUnwindSafe

impl<Tag, Extra> Send for Allocation<Tag, Extra> where
    Extra: Send,
    Tag: Send

impl<Tag, Extra> Sync for Allocation<Tag, Extra> where
    Extra: Sync,
    Tag: Sync

impl<Tag, Extra> Unpin for Allocation<Tag, Extra> where
    Extra: Unpin,
    Tag: Unpin

impl<Tag, Extra> UnwindSafe for Allocation<Tag, Extra> where
    Extra: UnwindSafe,
    Tag: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<'a, T> Captures<'a> for T where
    T: ?Sized
[src]

impl<T> Cast for T

impl<T> Decodable for T where
    T: UseSpecializedDecodable
[src]

impl<Ctxt, T> DepNodeParams<Ctxt> for T where
    Ctxt: DepContext,
    T: HashStable<<Ctxt as DepContext>::StableHashingContext> + Debug
[src]

impl<T> Encodable for T where
    T: UseSpecializedEncodable + ?Sized
[src]

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

impl<T> Erased for T[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> IntoSelfProfilingString for T where
    T: Debug
[src]

impl<T> IntoSelfProfilingString for T where
    T: SpecIntoSelfProfilingString
[src]

impl<T> MaybeResult<T> for T[src]

type Error = !

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

impl<T> Same<T> for T

type Output = T

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Should always be Self

impl<E> SpecializationError for E[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> WithConstness for T[src]