Trait BodyTransformCtx

Source
pub trait BodyTransformCtx: Sized {
    // Required methods
    fn get_ctx(&self) -> &TransformCtx;
    fn get_params(&self) -> &GenericParams;
    fn get_locals_mut(&mut self) -> &mut Locals;
    fn insert_storage_live_stmt(&mut self, local: LocalId);
    fn insert_storage_dead_stmt(&mut self, local: LocalId);
    fn insert_assn_stmt(&mut self, place: Place, rvalue: Rvalue);

    // Provided methods
    fn fresh_var(&mut self, name: Option<String>, ty: Ty) -> Place { ... }
    fn compute_subslice_end_idx(
        &mut self,
        len_place: &Place,
        last_arg: Operand,
        from_end: bool,
    ) -> Operand { ... }
    fn is_sized_type_var(&mut self, ty: &Ty) -> bool { ... }
    fn compute_place_metadata(&mut self, place: &Place) -> Operand { ... }
}
Expand description

A helper trait that captures the usual operation in body transformation.

Required Methods§

Source

fn get_ctx(&self) -> &TransformCtx

Source

fn get_params(&self) -> &GenericParams

Source

fn get_locals_mut(&mut self) -> &mut Locals

Source

fn insert_storage_live_stmt(&mut self, local: LocalId)

Source

fn insert_storage_dead_stmt(&mut self, local: LocalId)

Source

fn insert_assn_stmt(&mut self, place: Place, rvalue: Rvalue)

Provided Methods§

Source

fn fresh_var(&mut self, name: Option<String>, ty: Ty) -> Place

Create a local & return the place pointing to it

Source

fn compute_subslice_end_idx( &mut self, len_place: &Place, last_arg: Operand, from_end: bool, ) -> Operand

When from_end is true, we need to compute len(p) - last_arg instead of just using last_arg. Otherwise, we simply return last_arg. New local variables are created as needed.

The last_arg is either the offset for Index or the to for Subslice for the projections.

Source

fn is_sized_type_var(&mut self, ty: &Ty) -> bool

Source

fn compute_place_metadata(&mut self, place: &Place) -> Operand

Emit statements that compute the metadata of the given place. Returns an operand containing the metadata value.

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§