BodyTransformCtx

Trait BodyTransformCtx 

Source
pub trait BodyTransformCtx: Sized {
Show 17 methods // Required methods fn get_crate(&self) -> &TranslatedCrate; fn get_options(&self) -> &TranslateOptions; 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 into_fmt(&self) -> FmtCtx<'_> { ... } fn fresh_var(&mut self, name: Option<String>, ty: Ty) -> Place { ... } fn rval_to_place(&mut self, rvalue: Rvalue, 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 { ... } fn borrow(&mut self, place: Place, kind: BorrowKind) -> Rvalue { ... } fn raw_borrow(&mut self, place: Place, kind: RefKind) -> Rvalue { ... } fn borrow_to_new_var( &mut self, place: Place, kind: BorrowKind, name: Option<String>, ) -> Place { ... } fn raw_borrow_to_new_var( &mut self, place: Place, kind: RefKind, name: Option<String>, ) -> Place { ... }
}
Expand description

A helper trait that captures common operations in body transformation.

Required Methods§

Provided Methods§

Source

fn into_fmt(&self) -> FmtCtx<'_>

Source

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

Create a local & return the place pointing to it

Source

fn rval_to_place(&mut self, rvalue: Rvalue, ty: Ty) -> Place

Assign an rvalue to a place, unless the rvalue is a move in which case we just use the moved place.

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.

E.g., for:

let x = &(*ptr).field;

if (*ptr).field is a DST like [i32], this will get the metadata from the appropriate pointer:

let len = ptr.metadata;

and return Operand::Move(len).

Source

fn borrow(&mut self, place: Place, kind: BorrowKind) -> Rvalue

Create a & borrow of the place.

Source

fn raw_borrow(&mut self, place: Place, kind: RefKind) -> Rvalue

Create a &raw borrow of the place.

Source

fn borrow_to_new_var( &mut self, place: Place, kind: BorrowKind, name: Option<String>, ) -> Place

Store a & borrow of the place into a new place.

Source

fn raw_borrow_to_new_var( &mut self, place: Place, kind: RefKind, name: Option<String>, ) -> Place

Store a &raw borrow of the place into a new place.

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§