Skip to main content

MirLowerCtx

Struct MirLowerCtx 

Source
struct MirLowerCtx<'a, 'db> {
Show 14 fields result: MirBody<'db>, owner: InferBodyId<'db>, store_owner: ExpressionStoreOwnerId, current_loop_blocks: Option<LoopBlocks>, labeled_loop_blocks: FxHashMap<LabelId, LoopBlocks>, discr_temp: Option<Place>, db: &'db dyn HirDatabase, store: &'a ExpressionStore, infer: &'a InferenceResult<'db>, types: &'db DefaultAny<'db>, resolver: Resolver<'db>, drop_scopes: Vec<DropScope>, env: ParamEnv<'db>, infcx: InferCtxt<'db>,
}

Fields§

§result: MirBody<'db>§owner: InferBodyId<'db>§store_owner: ExpressionStoreOwnerId§current_loop_blocks: Option<LoopBlocks>§labeled_loop_blocks: FxHashMap<LabelId, LoopBlocks>§discr_temp: Option<Place>§db: &'db dyn HirDatabase§store: &'a ExpressionStore§infer: &'a InferenceResult<'db>§types: &'db DefaultAny<'db>§resolver: Resolver<'db>§drop_scopes: Vec<DropScope>§env: ParamEnv<'db>§infcx: InferCtxt<'db>

Implementations§

Source§

impl<'db> MirLowerCtx<'_, 'db>

Source

fn lower_expr_to_some_place_without_adjust( &mut self, expr_id: ExprId, prev_block: BasicBlockId, ) -> Result<Option<(PlaceRef<'db>, BasicBlockId)>, MirLowerError<'db>>

Source

fn lower_expr_to_some_place_with_adjust( &mut self, expr_id: ExprId, prev_block: BasicBlockId, adjustments: &[Adjustment], ) -> Result<Option<(PlaceRef<'db>, BasicBlockId)>, MirLowerError<'db>>

Source

pub(super) fn lower_expr_as_place_with_adjust( &mut self, current: BasicBlockId, expr_id: ExprId, upgrade_rvalue: bool, adjustments: &[Adjustment], ) -> Result<Option<(PlaceRef<'db>, BasicBlockId)>, MirLowerError<'db>>

Source

pub(super) fn lower_expr_as_place( &mut self, current: BasicBlockId, expr_id: ExprId, upgrade_rvalue: bool, ) -> Result<Option<(PlaceRef<'db>, BasicBlockId)>, MirLowerError<'db>>

Source

pub(super) fn lower_expr_as_place_without_adjust( &mut self, current: BasicBlockId, expr_id: ExprId, upgrade_rvalue: bool, ) -> Result<Option<(PlaceRef<'db>, BasicBlockId)>, MirLowerError<'db>>

Source

fn lower_overloaded_index( &mut self, current: BasicBlockId, place: PlaceRef<'db>, base_ty: Ty<'db>, result_ty: Ty<'db>, index_operand: Operand, span: MirSpan, index_fn: (FunctionId, GenericArgs<'db>), ) -> Result<Option<(PlaceRef<'db>, BasicBlockId)>, MirLowerError<'db>>

Source

fn lower_overloaded_deref( &mut self, current: BasicBlockId, place: PlaceRef<'db>, source_ty: Ty<'db>, target_ty: Ty<'db>, span: MirSpan, mutability: bool, ) -> Result<Option<(PlaceRef<'db>, BasicBlockId)>, MirLowerError<'db>>

Source§

impl<'db> MirLowerCtx<'_, 'db>

Source

pub(super) fn pattern_match( &mut self, current: BasicBlockId, current_else: Option<BasicBlockId>, cond_place: PlaceRef<'db>, pattern: PatId, ) -> Result<(BasicBlockId, Option<BasicBlockId>), MirLowerError<'db>>

It gets a current unterminated block, appends some statements and possibly a terminator to it to check if the pattern matches and write bindings, and returns two unterminated blocks, one for the matched path (which can be the current block) and one for the mismatched path. If the input pattern is irrefutable, the mismatched path block is None.

By default, it will create a new block for mismatched path. If you already have one, you can provide it with current_else argument to save an unnecessary jump. If current_else isn’t None, the result mismatched path wouldn’t be None as well. Note that this function will add jumps to the beginning of the current_else block, so it should be an empty block.

Source

pub(super) fn pattern_match_assignment( &mut self, current: BasicBlockId, value: PlaceRef<'db>, pattern: PatId, ) -> Result<BasicBlockId, MirLowerError<'db>>

Source

pub(super) fn match_self_param( &mut self, id: BindingId, current: BasicBlockId, local: LocalId, ) -> Result<(BasicBlockId, Option<BasicBlockId>), MirLowerError<'db>>

Source

fn pattern_match_inner( &mut self, current: BasicBlockId, current_else: Option<BasicBlockId>, cond_place: PlaceRef<'db>, pattern: PatId, mode: MatchingMode, ) -> Result<(BasicBlockId, Option<BasicBlockId>), MirLowerError<'db>>

Source

fn pattern_match_binding( &mut self, id: BindingId, mode: BindingMode, cond_place: PlaceRef<'db>, span: MirSpan, current: BasicBlockId, current_else: Option<BasicBlockId>, ) -> Result<(BasicBlockId, Option<BasicBlockId>), MirLowerError<'db>>

Source

fn push_match_assignment( &mut self, current: BasicBlockId, target_place: LocalId, mode: BindingMode, cond_place: PlaceRef<'db>, span: MirSpan, )

Source

fn pattern_match_const( &mut self, current_else: Option<BasicBlockId>, current: BasicBlockId, c: Operand, cond_place: PlaceRef<'db>, pattern: Idx<Pat>, ) -> Result<(BasicBlockId, Option<BasicBlockId>), MirLowerError<'db>>

Source

fn pattern_matching_variant( &mut self, cond_place: PlaceRef<'db>, variant: VariantId, current: BasicBlockId, span: MirSpan, current_else: Option<BasicBlockId>, shape: AdtPatternShape<'_>, mode: MatchingMode, ) -> Result<(BasicBlockId, Option<BasicBlockId>), MirLowerError<'db>>

Source

fn pattern_matching_variant_fields( &mut self, shape: AdtPatternShape<'_>, variant_data: &VariantFields, v: VariantId, current: BasicBlockId, current_else: Option<BasicBlockId>, cond_place: &PlaceRef<'db>, mode: MatchingMode, ) -> Result<(BasicBlockId, Option<BasicBlockId>), MirLowerError<'db>>

Source

fn pattern_match_adt( &mut self, current: BasicBlockId, current_else: Option<BasicBlockId>, args: impl Iterator<Item = (ProjectionElem<LocalId>, PatId)>, cond_place: &PlaceRef<'db>, mode: MatchingMode, ) -> Result<(BasicBlockId, Option<BasicBlockId>), MirLowerError<'db>>

Source

fn pattern_match_tuple_like( &mut self, current: BasicBlockId, current_else: Option<BasicBlockId>, args: &[PatId], ellipsis: Option<u32>, fields: impl DoubleEndedIterator<Item = ProjectionElem<LocalId>> + Clone, cond_place: &PlaceRef<'db>, mode: MatchingMode, ) -> Result<(BasicBlockId, Option<BasicBlockId>), MirLowerError<'db>>

Source§

impl<'a, 'db> MirLowerCtx<'a, 'db>

Source

fn new( db: &'db dyn HirDatabase, owner: InferBodyId<'db>, store: &'a ExpressionStore, infer: &'a InferenceResult<'db>, ) -> Self

Source

fn interner(&self) -> DbInterner<'db>

Source

fn lang_items(&self) -> &'db LangItems

Source

fn temp( &mut self, ty: Ty<'db>, current: BasicBlockId, span: MirSpan, ) -> Result<LocalId, MirLowerError<'db>>

Source

fn lower_expr_to_some_operand( &mut self, expr_id: ExprId, current: BasicBlockId, ) -> Result<Option<(Operand, BasicBlockId)>, MirLowerError<'db>>

Source

fn lower_expr_to_place_with_adjust( &mut self, expr_id: ExprId, place: PlaceRef<'db>, current: BasicBlockId, adjustments: &[Adjustment], ) -> Result<Option<BasicBlockId>, MirLowerError<'db>>

Source

fn lower_expr_to_place_with_borrow_adjust( &mut self, expr_id: ExprId, place: PlaceRef<'db>, current: BasicBlockId, rest: &[Adjustment], m: Mutability, ) -> Result<Option<BasicBlockId>, MirLowerError<'db>>

Source

fn lower_expr_to_place( &mut self, expr_id: ExprId, place: PlaceRef<'db>, prev_block: BasicBlockId, ) -> Result<Option<BasicBlockId>, MirLowerError<'db>>

Source

fn lower_expr_to_place_without_adjust( &mut self, expr_id: ExprId, place: PlaceRef<'db>, current: BasicBlockId, ) -> Result<Option<BasicBlockId>, MirLowerError<'db>>

Source

fn push_field_projection( &mut self, place: &mut PlaceRef<'db>, expr_id: ExprId, ) -> Result<(), MirLowerError<'db>>

Source

fn lower_literal_or_const_to_operand( &mut self, ty: Ty<'db>, loc: &ExprId, ) -> Result<Operand, MirLowerError<'db>>

Source

fn lower_literal_to_operand( &mut self, ty: Ty<'db>, l: &Literal, ) -> Result<Operand, MirLowerError<'db>>

Source

fn new_basic_block(&mut self) -> BasicBlockId

Source

fn lower_const( &mut self, const_id: GeneralConstId<'db>, prev_block: BasicBlockId, place: PlaceRef<'db>, subst: GenericArgs<'db>, span: MirSpan, ) -> Result<(), MirLowerError<'db>>

Source

fn lower_const_to_operand( &mut self, subst: GenericArgs<'db>, const_id: GeneralConstId<'db>, ) -> Result<Operand, MirLowerError<'db>>

Source

fn write_bytes_to_place( &mut self, prev_block: BasicBlockId, place: PlaceRef<'db>, cv: Box<[u8]>, ty: Ty<'db>, span: MirSpan, ) -> Result<(), MirLowerError<'db>>

Source

fn lower_enum_variant( &mut self, variant_id: EnumVariantId, prev_block: BasicBlockId, place: PlaceRef<'db>, ty: Ty<'db>, fields: Box<[Operand]>, span: MirSpan, ) -> Result<BasicBlockId, MirLowerError<'db>>

Source

fn lower_call_and_args( &mut self, func: Operand, args: impl Iterator<Item = ExprId>, place: PlaceRef<'db>, current: BasicBlockId, is_uninhabited: bool, span: MirSpan, ) -> Result<Option<BasicBlockId>, MirLowerError<'db>>

Source

fn lower_call( &mut self, func: Operand, args: Box<[Operand]>, place: PlaceRef<'db>, current: BasicBlockId, is_uninhabited: bool, span: MirSpan, ) -> Result<Option<BasicBlockId>, MirLowerError<'db>>

Source

fn is_unterminated(&mut self, source: BasicBlockId) -> bool

Source

fn set_terminator( &mut self, source: BasicBlockId, terminator: TerminatorKind, span: MirSpan, )

Source

fn set_goto( &mut self, source: BasicBlockId, target: BasicBlockId, span: MirSpan, )

Source

fn expr_ty_without_adjust(&self, e: ExprId) -> Ty<'db>

Source

fn expr_ty_after_adjustments(&self, e: ExprId) -> Ty<'db>

Source

fn push_statement(&mut self, block: BasicBlockId, statement: Statement)

Source

fn push_fake_read( &mut self, block: BasicBlockId, p: PlaceRef<'db>, span: MirSpan, )

Source

fn push_assignment( &mut self, block: BasicBlockId, place: PlaceRef<'db>, rvalue: Rvalue, span: MirSpan, )

Source

fn discr_temp_place(&mut self, current: BasicBlockId) -> PlaceRef<'db>

Source

fn lower_loop( &mut self, prev_block: BasicBlockId, place: PlaceRef<'db>, label: Option<LabelId>, span: MirSpan, f: impl FnOnce(&mut MirLowerCtx<'_, 'db>, BasicBlockId) -> Result<(), MirLowerError<'db>>, ) -> Result<Option<BasicBlockId>, MirLowerError<'db>>

Source

fn has_adjustments(&self, expr_id: ExprId) -> bool

Source

fn merge_blocks( &mut self, b1: Option<BasicBlockId>, b2: Option<BasicBlockId>, span: MirSpan, ) -> Option<BasicBlockId>

Source

fn current_loop_end(&mut self) -> Result<BasicBlockId, MirLowerError<'db>>

Source

fn is_uninhabited(&self, expr_id: ExprId) -> bool

Source

fn push_storage_live( &mut self, b: BindingId, current: BasicBlockId, ) -> Result<(), MirLowerError<'db>>

This function push StorageLive statement for the binding, and applies changes to add StorageDead and Drop in the appropriated places.

Source

fn push_storage_live_for_local( &mut self, l: LocalId, current: BasicBlockId, span: MirSpan, ) -> Result<(), MirLowerError<'db>>

Source

fn lower_block_to_place( &mut self, statements: &[Statement], current: BasicBlockId, tail: Option<ExprId>, place: PlaceRef<'db>, span: MirSpan, ) -> Result<Option<Idx<BasicBlock>>, MirLowerError<'db>>

Source

fn lower_params_and_bindings( &mut self, params: impl Iterator<Item = (PatId, Ty<'db>)> + Clone, self_binding: Option<(BindingId, Ty<'db>)>, pick_binding: impl Fn(BindingId) -> bool, ) -> Result<BasicBlockId, MirLowerError<'db>>

Source

fn binding_local(&self, b: BindingId) -> Result<LocalId, MirLowerError<'db>>

Source

fn const_eval_discriminant( &self, variant: EnumVariantId, ) -> Result<i128, MirLowerError<'db>>

Source

fn edition(&self) -> Edition

Source

fn krate(&self) -> Crate

Source

fn display_target(&self) -> DisplayTarget

Source

fn drop_until_scope( &mut self, scope_index: usize, current: BasicBlockId, span: MirSpan, ) -> BasicBlockId

Source

fn push_drop_scope(&mut self) -> DropScopeToken

Source

fn pop_drop_scope_assume_dropped_internal(&mut self)

Don’t call directly

Source

fn pop_drop_scope_internal( &mut self, current: BasicBlockId, span: MirSpan, ) -> BasicBlockId

Don’t call directly

Source

fn pop_drop_scope_assert_finished( &mut self, current: BasicBlockId, span: MirSpan, ) -> Result<BasicBlockId, MirLowerError<'db>>

Source

fn emit_drop_and_storage_dead_for_scope( &mut self, scope: &DropScope, current: &mut Idx<BasicBlock>, span: MirSpan, )

Auto Trait Implementations§

§

impl<'a, 'db> !Freeze for MirLowerCtx<'a, 'db>

§

impl<'a, 'db> !RefUnwindSafe for MirLowerCtx<'a, 'db>

§

impl<'a, 'db> !Send for MirLowerCtx<'a, 'db>

§

impl<'a, 'db> !Sync for MirLowerCtx<'a, 'db>

§

impl<'a, 'db> Unpin for MirLowerCtx<'a, 'db>

§

impl<'a, 'db> UnsafeUnpin for MirLowerCtx<'a, 'db>

§

impl<'a, 'db> !UnwindSafe for MirLowerCtx<'a, 'db>

Blanket Implementations§

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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.

§

impl<T> IntoBox<dyn Any> for T
where T: Any,

§

fn into_box(self) -> Box<dyn Any>

Convert self into the appropriate boxed form.
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
§

impl<T> Lookup<T> for T

§

fn into_owned(self) -> T

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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