Provenance in rustc_middle::mir::interpret::pointer - Rust
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. The `Debug` rendering is used to display bare provenance, and for the default impl of `fmt`.

Skip to main content

## Provenance

# Trait Provenance

Source

    pub trait Provenance:
        Copy
        + PartialEq
        + Debug
        + 'static {
        const OFFSET_IS_ADDR: bool;
        const WILDCARD: Option<Self>;

        // Required methods
        fn fmt(ptr: &Pointer<Self>, f: &mut Formatter<'_>) -> Result;
        fn get_alloc_id(self) -> Option<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. The `Debug` rendering is used to display bare provenance, and for the default impl of `fmt`.

## Required Associated Constants§

Source

#### const OFFSET_IS_ADDR: bool

Says whether the `offset` field of `Pointer`s with this provenance is the actual physical address.

- If `false`, the offset must be relative. This means the bytes representing a pointer are different from what the Abstract Machine prescribes, so the interpreter must prevent any operation that would inspect the underlying bytes of a pointer, such as ptr-to-int transmutation. A `ReadPointerAsBytes` error will be raised in such situations.
- If `true`, the interpreter will permit operations to inspect the underlying bytes of a pointer, and implement ptr-to-int transmutation by stripping provenance.

Source

#### const WILDCARD: Option<Self>

If wildcard provenance is implemented, contains the unique, general wildcard provenance variant.

## Required Methods§

Source

#### fn fmt(ptr: &Pointer<Self>, f: &mut Formatter<'_>) -> Result

Determines how a pointer should be printed.

Source

#### fn get_alloc_id(self) -> Option<AllocId>

If `OFFSET_IS_ADDR == false`, provenance must always be able to identify the allocation this ptr points to (i.e., this must return `Some`). Otherwise this function is best-effort (but must agree with `Machine::ptr_get_alloc`). (Identifying the offset in that allocation, however, is harder – use `Memory::ptr_get_alloc` for that.)

## Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

## Implementors§

Source§

### impl Provenance for AllocId

Source§

#### const OFFSET_IS_ADDR: bool = false

Source§

#### const WILDCARD: Option<Self> = None

Source§

### impl Provenance for CtfeProvenance

Source§

#### const OFFSET_IS_ADDR: bool = false

Source§

#### const WILDCARD: Option<Self> = None