rustc_mir_dataflow::elaborate_drops

Trait DropElaborator

Source
pub trait DropElaborator<'a, 'tcx>: Debug {
    type Path: Copy + Debug;

    // Required methods
    fn patch(&mut self) -> &mut MirPatch<'tcx>;
    fn body(&self) -> &'a Body<'tcx>;
    fn tcx(&self) -> TyCtxt<'tcx>;
    fn typing_env(&self) -> TypingEnv<'tcx>;
    fn drop_style(&self, path: Self::Path, mode: DropFlagMode) -> DropStyle;
    fn get_drop_flag(&mut self, path: Self::Path) -> Option<Operand<'tcx>>;
    fn clear_drop_flag(
        &mut self,
        location: Location,
        path: Self::Path,
        mode: DropFlagMode,
    );
    fn field_subpath(
        &self,
        path: Self::Path,
        field: FieldIdx,
    ) -> Option<Self::Path>;
    fn deref_subpath(&self, path: Self::Path) -> Option<Self::Path>;
    fn downcast_subpath(
        &self,
        path: Self::Path,
        variant: VariantIdx,
    ) -> Option<Self::Path>;
    fn array_subpath(
        &self,
        path: Self::Path,
        index: u64,
        size: u64,
    ) -> Option<Self::Path>;
}

Required Associated Types§

Source

type Path: Copy + Debug

The type representing paths that can be moved out of.

Users can move out of individual fields of a struct, such as a.b.c. This type is used to represent such move paths. Sometimes tracking individual move paths is not necessary, in which case this may be set to (for example) ().

Required Methods§

Source

fn patch(&mut self) -> &mut MirPatch<'tcx>

Source

fn body(&self) -> &'a Body<'tcx>

Source

fn tcx(&self) -> TyCtxt<'tcx>

Source

fn typing_env(&self) -> TypingEnv<'tcx>

Source

fn drop_style(&self, path: Self::Path, mode: DropFlagMode) -> DropStyle

Returns how path should be dropped, given mode.

Source

fn get_drop_flag(&mut self, path: Self::Path) -> Option<Operand<'tcx>>

Returns the drop flag of path as a MIR Operand (or None if path has no drop flag).

Source

fn clear_drop_flag( &mut self, location: Location, path: Self::Path, mode: DropFlagMode, )

Modifies the MIR patch so that the drop flag of path (if any) is cleared at location.

If mode is deep, drop flags of all child paths should also be cleared by inserting additional statements.

Source

fn field_subpath(&self, path: Self::Path, field: FieldIdx) -> Option<Self::Path>

Returns the subpath of a field of path (or None if there is no dedicated subpath).

If this returns None, field will not get a dedicated drop flag.

Source

fn deref_subpath(&self, path: Self::Path) -> Option<Self::Path>

Returns the subpath of a dereference of path (or None if there is no dedicated subpath).

If this returns None, *path will not get a dedicated drop flag.

This is only relevant for Box<T>, where the contained T can be moved out of the box.

Source

fn downcast_subpath( &self, path: Self::Path, variant: VariantIdx, ) -> Option<Self::Path>

Returns the subpath of downcasting path to one of its variants.

If this returns None, the downcast of path will not get a dedicated drop flag.

Source

fn array_subpath( &self, path: Self::Path, index: u64, size: u64, ) -> Option<Self::Path>

Returns the subpath of indexing a fixed-size array path.

If this returns None, elements of path will not get a dedicated drop flag.

This is only relevant for array patterns, which can move out of individual array elements.

Implementors§