rustc_const_eval::interpret::projection

Trait Projectable

Source
pub trait Projectable<'tcx, Prov: Provenance>: Sized + Debug {
    // Required methods
    fn layout(&self) -> TyAndLayout<'tcx>;
    fn meta(&self) -> MemPlaceMeta<Prov>;
    fn offset_with_meta<M: Machine<'tcx, Provenance = Prov>>(
        &self,
        offset: Size,
        mode: OffsetMode,
        meta: MemPlaceMeta<Prov>,
        layout: TyAndLayout<'tcx>,
        ecx: &InterpCx<'tcx, M>,
    ) -> InterpResult<'tcx, Self>;
    fn to_op<M: Machine<'tcx, Provenance = Prov>>(
        &self,
        ecx: &InterpCx<'tcx, M>,
    ) -> InterpResult<'tcx, OpTy<'tcx, M::Provenance>>;

    // Provided methods
    fn len<M: Machine<'tcx, Provenance = Prov>>(
        &self,
        ecx: &InterpCx<'tcx, M>,
    ) -> InterpResult<'tcx, u64> { ... }
    fn offset<M: Machine<'tcx, Provenance = Prov>>(
        &self,
        offset: Size,
        layout: TyAndLayout<'tcx>,
        ecx: &InterpCx<'tcx, M>,
    ) -> InterpResult<'tcx, Self> { ... }
    fn transmute<M: Machine<'tcx, Provenance = Prov>>(
        &self,
        layout: TyAndLayout<'tcx>,
        ecx: &InterpCx<'tcx, M>,
    ) -> InterpResult<'tcx, Self> { ... }
}
Expand description

A thing that we can project into, and that has a layout.

Required Methods§

Source

fn layout(&self) -> TyAndLayout<'tcx>

Get the layout.

Source

fn meta(&self) -> MemPlaceMeta<Prov>

Get the metadata of a wide value.

Source

fn offset_with_meta<M: Machine<'tcx, Provenance = Prov>>( &self, offset: Size, mode: OffsetMode, meta: MemPlaceMeta<Prov>, layout: TyAndLayout<'tcx>, ecx: &InterpCx<'tcx, M>, ) -> InterpResult<'tcx, Self>

Offset the value by the given amount, replacing the layout and metadata.

Source

fn to_op<M: Machine<'tcx, Provenance = Prov>>( &self, ecx: &InterpCx<'tcx, M>, ) -> InterpResult<'tcx, OpTy<'tcx, M::Provenance>>

Convert this to an OpTy. This might be an irreversible transformation, but is useful for reading from this thing.

Provided Methods§

Source

fn len<M: Machine<'tcx, Provenance = Prov>>( &self, ecx: &InterpCx<'tcx, M>, ) -> InterpResult<'tcx, u64>

Get the length of a slice/string/array stored here.

Source

fn offset<M: Machine<'tcx, Provenance = Prov>>( &self, offset: Size, layout: TyAndLayout<'tcx>, ecx: &InterpCx<'tcx, M>, ) -> InterpResult<'tcx, Self>

Source

fn transmute<M: Machine<'tcx, Provenance = Prov>>( &self, layout: TyAndLayout<'tcx>, ecx: &InterpCx<'tcx, M>, ) -> InterpResult<'tcx, Self>

This does an offset-by-zero, which is effectively a transmute. Note however that not all transmutes are supported by all projectables – specifically, if this is an OpTy or ImmTy, the new layout must have almost the same ABI as the old one (only changing the valid_range is allowed and turning integers into pointers).

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<'tcx, Prov: Provenance> Projectable<'tcx, Prov> for ImmTy<'tcx, Prov>

Source§

impl<'tcx, Prov: Provenance> Projectable<'tcx, Prov> for OpTy<'tcx, Prov>

Source§

impl<'tcx, Prov: Provenance> Projectable<'tcx, Prov> for MPlaceTy<'tcx, Prov>

Source§

impl<'tcx, Prov: Provenance> Projectable<'tcx, Prov> for PlaceTy<'tcx, Prov>