Trait rustc_middle::mir::interpret::pointer::Provenance[][src]

pub trait Provenance: Copy + Debug {
    const OFFSET_IS_ADDR: bool;

    fn fmt(ptr: &Pointer<Self>, f: &mut Formatter<'_>) -> Result
        Self: Sized
fn get_alloc_id(self) -> AllocId; }
Expand description

This trait abstracts over the kind of provenance that is associated with a Pointer. It is mostly opaque; the Machine trait extends it with some more operations that also have access to some global state. We don’t actually care about this Debug bound (we use Provenance::fmt to format the entire pointer), but derive adds some unecessary bounds.

Associated Constants

Says whether the offset field of Pointers with this provenance is the actual physical address. If true, ptr-to-int casts work by simply discarding the provenance. If false`, ptr-to-int casts are not supported. The offset must be relative in that case.

We also use this trait to control whether to abort execution when a pointer is being partially overwritten (this avoids a separate trait in just for this purpose).

Required methods

Determines how a pointer should be printed.

Provenance must always be able to identify the allocation this ptr points to. (Identifying the offset in that allocation, however, is harder – use Memory::ptr_get_alloc for that.)