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 param_env(&self) -> ParamEnv<'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 param_env(&self) -> ParamEnv<'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§