rustc_mir_dataflow::elaborate_drops

Struct DropCtxt

Source
struct DropCtxt<'a, 'b, 'tcx, D>
where D: DropElaborator<'b, 'tcx>,
{ elaborator: &'a mut D, source_info: SourceInfo, place: Place<'tcx>, path: D::Path, succ: BasicBlock, unwind: Unwind, }

Fields§

§elaborator: &'a mut D§source_info: SourceInfo§place: Place<'tcx>§path: D::Path§succ: BasicBlock§unwind: Unwind

Implementations§

Source§

impl<'a, 'b, 'tcx, D> DropCtxt<'a, 'b, 'tcx, D>
where D: DropElaborator<'b, 'tcx>, 'tcx: 'b,

Source

fn place_ty(&self, place: Place<'tcx>) -> Ty<'tcx>

Source

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

Source

fn elaborate_drop(&mut self, bb: BasicBlock)

This elaborates a single drop instruction, located at bb, and patches over it.

The elaborated drop checks the drop flags to only drop what is initialized.

In addition, the relevant drop flags also need to be cleared to avoid double-drops. However, in the middle of a complex drop, one must avoid clearing some of the flags before they are read, as that would cause a memory leak.

In particular, when dropping an ADT, multiple fields may be joined together under the rest subpath. They are all controlled by the primary drop flag, but only the last rest-field dropped should clear it (and it must also not clear anything else).

Source

fn move_paths_for_fields( &self, base_place: Place<'tcx>, variant_path: D::Path, variant: &'tcx VariantDef, args: GenericArgsRef<'tcx>, ) -> Vec<(Place<'tcx>, Option<D::Path>)>

Returns the place and move path for each field of variant, (the move path is None if the field is a rest field).

Source

fn drop_subpath( &mut self, place: Place<'tcx>, path: Option<D::Path>, succ: BasicBlock, unwind: Unwind, ) -> BasicBlock

Source

fn drop_halfladder( &mut self, unwind_ladder: &[Unwind], succ: BasicBlock, fields: &[(Place<'tcx>, Option<D::Path>)], ) -> Vec<BasicBlock>

Creates one-half of the drop ladder for a list of fields, and return the list of steps in it in reverse order, with the first step dropping 0 fields and so on.

unwind_ladder is such a list of steps in reverse order, which is called if the matching step of the drop glue panics.

Source

fn drop_ladder_bottom(&mut self) -> (BasicBlock, Unwind)

Source

fn drop_ladder( &mut self, fields: Vec<(Place<'tcx>, Option<D::Path>)>, succ: BasicBlock, unwind: Unwind, ) -> (BasicBlock, Unwind)

Creates a full drop ladder, consisting of 2 connected half-drop-ladders

For example, with 3 fields, the drop ladder is

.d0: ELAB(drop location.0 [target=.d1, unwind=.c1]) .d1: ELAB(drop location.1 [target=.d2, unwind=.c2]) .d2: ELAB(drop location.2 [target=self.succ, unwind=self.unwind]) .c1: ELAB(drop location.1 [target=.c2]) .c2: ELAB(drop location.2 [target=self.unwind])

NOTE: this does not clear the master drop flag, so you need to point succ/unwind on a drop_ladder_bottom.

Source

fn open_drop_for_tuple(&mut self, tys: &[Ty<'tcx>]) -> BasicBlock

Source

fn open_drop_for_box_contents( &mut self, adt: AdtDef<'tcx>, args: GenericArgsRef<'tcx>, succ: BasicBlock, unwind: Unwind, ) -> BasicBlock

Drops the T contained in a Box<T> if it has not been moved out of

Source

fn open_drop_for_adt( &mut self, adt: AdtDef<'tcx>, args: GenericArgsRef<'tcx>, ) -> BasicBlock

Source

fn open_drop_for_adt_contents( &mut self, adt: AdtDef<'tcx>, args: GenericArgsRef<'tcx>, ) -> (BasicBlock, Unwind)

Source

fn open_drop_for_multivariant( &mut self, adt: AdtDef<'tcx>, args: GenericArgsRef<'tcx>, succ: BasicBlock, unwind: Unwind, ) -> (BasicBlock, Unwind)

Source

fn adt_switch_block( &mut self, adt: AdtDef<'tcx>, blocks: Vec<BasicBlock>, values: &[u128], succ: BasicBlock, unwind: Unwind, ) -> BasicBlock

Source

fn destructor_call_block( &mut self, (succ, unwind): (BasicBlock, Unwind), ) -> BasicBlock

Source

fn drop_loop( &mut self, succ: BasicBlock, cur: Local, len: Local, ety: Ty<'tcx>, unwind: Unwind, ) -> BasicBlock

Create a loop that drops an array:

loop-block:
   can_go = cur == len
   if can_go then succ else drop-block
drop-block:
   ptr = &raw mut P[cur]
   cur = cur + 1
   drop(ptr)
Source

fn open_drop_for_array( &mut self, ety: Ty<'tcx>, opt_size: Option<u64>, ) -> BasicBlock

Source

fn drop_loop_pair(&mut self, ety: Ty<'tcx>) -> BasicBlock

Creates a pair of drop-loops of place, which drops its contents, even in the case of 1 panic.

Source

fn open_drop(&mut self) -> BasicBlock

The slow-path - create an “open”, elaborated drop for a type which is moved-out-of only partially, and patch bb to a jump to it. This must not be called on ADTs with a destructor, as these can’t be moved-out-of, except for Box<T>, which is special-cased.

This creates a “drop ladder” that drops the needed fields of the ADT, both in the success case or if one of the destructors fail.

Source

fn complete_drop(&mut self, succ: BasicBlock, unwind: Unwind) -> BasicBlock

Source

fn drop_flag_reset_block( &mut self, mode: DropFlagMode, succ: BasicBlock, unwind: Unwind, ) -> BasicBlock

Creates a block that resets the drop flag. If mode is deep, all children drop flags will also be cleared.

Source

fn elaborated_drop_block(&mut self) -> BasicBlock

Source

fn drop_block(&mut self, target: BasicBlock, unwind: Unwind) -> BasicBlock

Source

fn goto_block(&mut self, target: BasicBlock, unwind: Unwind) -> BasicBlock

Source

fn drop_flag_test_block( &mut self, on_set: BasicBlock, on_unset: BasicBlock, unwind: Unwind, ) -> BasicBlock

Returns the block to jump to in order to test the drop flag and execute the drop.

Depending on the required DropStyle, this might be a generated block with an if terminator (for dynamic/open drops), or it might be on_set or on_unset itself, in case the drop can be statically determined.

Source

fn new_block(&mut self, unwind: Unwind, k: TerminatorKind<'tcx>) -> BasicBlock

Source

fn new_temp(&mut self, ty: Ty<'tcx>) -> Local

Source

fn constant_usize(&self, val: u16) -> Operand<'tcx>

Source

fn assign(&self, lhs: Place<'tcx>, rhs: Rvalue<'tcx>) -> Statement<'tcx>

Trait Implementations§

Source§

impl<'a, 'b, 'tcx, D> Debug for DropCtxt<'a, 'b, 'tcx, D>
where D: DropElaborator<'b, 'tcx> + Debug, D::Path: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, 'b, 'tcx, D> DynSend for DropCtxt<'a, 'b, 'tcx, D>
where <D as DropElaborator<'b, 'tcx>>::Path: DynSend, D: DynSend,

§

impl<'a, 'b, 'tcx, D> DynSync for DropCtxt<'a, 'b, 'tcx, D>
where <D as DropElaborator<'b, 'tcx>>::Path: DynSync, D: DynSync,

§

impl<'a, 'b, 'tcx, D> Freeze for DropCtxt<'a, 'b, 'tcx, D>
where <D as DropElaborator<'b, 'tcx>>::Path: Freeze,

§

impl<'a, 'b, 'tcx, D> !RefUnwindSafe for DropCtxt<'a, 'b, 'tcx, D>

§

impl<'a, 'b, 'tcx, D> Send for DropCtxt<'a, 'b, 'tcx, D>
where <D as DropElaborator<'b, 'tcx>>::Path: Send, D: Send,

§

impl<'a, 'b, 'tcx, D> Sync for DropCtxt<'a, 'b, 'tcx, D>
where <D as DropElaborator<'b, 'tcx>>::Path: Sync, D: Sync,

§

impl<'a, 'b, 'tcx, D> Unpin for DropCtxt<'a, 'b, 'tcx, D>
where <D as DropElaborator<'b, 'tcx>>::Path: Unpin,

§

impl<'a, 'b, 'tcx, D> !UnwindSafe for DropCtxt<'a, 'b, 'tcx, D>

Blanket Implementations§

Source§

impl<T> Aligned for T

Source§

const ALIGN: Alignment = _

Alignment of Self.
Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T, R> CollectAndApply<T, R> for T

§

fn collect_and_apply<I, F>(iter: I, f: F) -> R
where I: Iterator<Item = T>, F: FnOnce(&[T]) -> R,

Equivalent to f(&iter.collect::<Vec<_>>()).

§

type Output = R

Source§

impl<T> Filterable for T

Source§

fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>

Creates a filterable data provider with the given name for debugging. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<P> IntoQueryParam<P> for P

Source§

impl<T> MaybeResult<T> for T

Source§

type Error = !

Source§

fn from(_: Result<T, <T as MaybeResult<T>>::Error>) -> T

Source§

fn to_result(self) -> Result<T, <T as MaybeResult<T>>::Error>

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize = _

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<I, T, U> Upcast<I, U> for T
where U: UpcastFrom<I, T>,

§

fn upcast(self, interner: I) -> U

§

impl<I, T> UpcastFrom<I, T> for T

§

fn upcast_from(from: T, _tcx: I) -> T

Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

§

impl<Tcx, T> Value<Tcx> for T
where Tcx: DepContext,

§

default fn from_cycle_error( tcx: Tcx, cycle_error: &CycleError, _guar: ErrorGuaranteed, ) -> T

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<'a, T> Captures<'a> for T
where T: ?Sized,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T
where T: Send + Sync,

Layout§

Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.