rustc_ast_lowering

Struct LoweringContext

Source
pub(crate) struct LoweringContext<'a, 'hir> {
Show 27 fields pub(crate) tcx: TyCtxt<'hir>, pub(crate) resolver: &'a mut ResolverAstLowering, pub(crate) arena: &'hir Arena<'hir>, pub(crate) bodies: Vec<(ItemLocalId, &'hir Body<'hir>)>, pub(crate) attrs: SortedMap<ItemLocalId, &'hir [Attribute]>, pub(crate) children: Vec<(LocalDefId, MaybeOwner<'hir>)>, pub(crate) coroutine_kind: Option<CoroutineKind>, pub(crate) task_context: Option<HirId>, pub(crate) current_item: Option<Span>, pub(crate) catch_scope: Option<HirId>, pub(crate) loop_scope: Option<HirId>, pub(crate) is_in_loop_condition: bool, pub(crate) is_in_trait_impl: bool, pub(crate) is_in_dyn_type: bool, pub(crate) current_hir_id_owner: OwnerId, pub(crate) current_def_id_parent: LocalDefId, pub(crate) item_local_id_counter: ItemLocalId, pub(crate) trait_map: ItemLocalMap<Box<[TraitCandidate]>>, pub(crate) impl_trait_defs: Vec<GenericParam<'hir>>, pub(crate) impl_trait_bounds: Vec<WherePredicate<'hir>>, pub(crate) ident_and_label_to_local_id: NodeMap<ItemLocalId>, pub(crate) node_id_to_local_id: NodeMap<ItemLocalId>, pub(crate) allow_try_trait: Lrc<[Symbol]>, pub(crate) allow_gen_future: Lrc<[Symbol]>, pub(crate) allow_async_iterator: Lrc<[Symbol]>, pub(crate) allow_for_await: Lrc<[Symbol]>, pub(crate) allow_async_fn_traits: Lrc<[Symbol]>,
}

Fields§

§tcx: TyCtxt<'hir>§resolver: &'a mut ResolverAstLowering§arena: &'hir Arena<'hir>

Used to allocate HIR nodes.

§bodies: Vec<(ItemLocalId, &'hir Body<'hir>)>

Bodies inside the owner being lowered.

§attrs: SortedMap<ItemLocalId, &'hir [Attribute]>

Attributes inside the owner being lowered.

§children: Vec<(LocalDefId, MaybeOwner<'hir>)>

Collect items that were created by lowering the current owner.

§coroutine_kind: Option<CoroutineKind>§task_context: Option<HirId>

When inside an async context, this is the HirId of the task_context local bound to the resume argument of the coroutine.

§current_item: Option<Span>

Used to get the current fn’s def span to point to when using await outside of an async fn.

§catch_scope: Option<HirId>§loop_scope: Option<HirId>§is_in_loop_condition: bool§is_in_trait_impl: bool§is_in_dyn_type: bool§current_hir_id_owner: OwnerId§current_def_id_parent: LocalDefId

Why do we need this in addition to Self::current_hir_id_owner?

Currently (as of June 2024), anonymous constants are not HIR owners; however, they do get their own DefIds. Some of these DefIds have to be created during AST lowering, rather than def collection, because we can’t tell until after name resolution whether an anonymous constant will end up instead being a hir::ConstArgKind::Path. However, to compute which generics are available to an anonymous constant nested inside another, we need to make sure that the parent is recorded as the parent anon const, not the enclosing item. So we need to track parent defs differently from HIR owners, since they will be finer-grained in the case of anon consts.

§item_local_id_counter: ItemLocalId§trait_map: ItemLocalMap<Box<[TraitCandidate]>>§impl_trait_defs: Vec<GenericParam<'hir>>§impl_trait_bounds: Vec<WherePredicate<'hir>>§ident_and_label_to_local_id: NodeMap<ItemLocalId>

NodeIds of pattern identifiers and labelled nodes that are lowered inside the current HIR owner.

§node_id_to_local_id: NodeMap<ItemLocalId>

NodeIds that are lowered inside the current HIR owner. Only used for duplicate lowering check.

§allow_try_trait: Lrc<[Symbol]>§allow_gen_future: Lrc<[Symbol]>§allow_async_iterator: Lrc<[Symbol]>§allow_for_await: Lrc<[Symbol]>§allow_async_fn_traits: Lrc<[Symbol]>

Implementations§

Source§

impl<'a, 'hir> LoweringContext<'a, 'hir>

Source

pub(crate) fn lower_inline_asm( &mut self, sp: Span, asm: &InlineAsm, ) -> &'hir InlineAsm<'hir>

Source§

impl<'a, 'hir> LoweringContext<'a, 'hir>

Source

pub(crate) fn lower_block( &mut self, b: &Block, targeted_by_break: bool, ) -> &'hir Block<'hir>

Source

pub(crate) fn lower_block_noalloc( &mut self, hir_id: HirId, b: &Block, targeted_by_break: bool, ) -> Block<'hir>

Source

fn lower_stmts( &mut self, ast_stmts: &[Stmt], ) -> (&'hir [Stmt<'hir>], Option<&'hir Expr<'hir>>)

Source

fn lower_local(&mut self, l: &Local) -> &'hir LetStmt<'hir>

Source

fn lower_block_check_mode(&mut self, b: &BlockCheckMode) -> BlockCheckMode

Source§

impl<'hir> LoweringContext<'_, 'hir>

Source

pub(crate) fn delegation_has_self( &self, item_id: NodeId, path_id: NodeId, span: Span, ) -> bool

Source

fn has_self(&self, def_id: DefId, span: Span) -> bool

Source

pub(crate) fn lower_delegation( &mut self, delegation: &Delegation, item_id: NodeId, ) -> DelegationResults<'hir>

Source

fn get_delegation_sig_id( &self, item_id: NodeId, path_id: NodeId, span: Span, ) -> Result<DefId, ErrorGuaranteed>

Source

fn get_resolution_id( &self, node_id: NodeId, span: Span, ) -> Result<DefId, ErrorGuaranteed>

Source

fn lower_delegation_generics(&mut self, span: Span) -> &'hir Generics<'hir>

Source

fn param_count(&self, sig_id: DefId) -> (usize, bool)

Source

fn lower_delegation_decl( &mut self, sig_id: DefId, param_count: usize, c_variadic: bool, span: Span, ) -> &'hir FnDecl<'hir>

Source

fn lower_delegation_sig( &mut self, sig_id: DefId, decl: &'hir FnDecl<'hir>, span: Span, ) -> FnSig<'hir>

Source

fn generate_param(&mut self, span: Span) -> (Param<'hir>, NodeId)

Source

fn generate_arg(&mut self, param_id: HirId, span: Span) -> Expr<'hir>

Source

fn lower_delegation_body( &mut self, delegation: &Delegation, param_count: usize, span: Span, ) -> BodyId

Source

fn lower_target_expr(&mut self, block: &Block) -> Expr<'hir>

Source

fn finalize_body_lowering( &mut self, delegation: &Delegation, args: Vec<Expr<'hir>>, span: Span, ) -> Expr<'hir>

Source

fn generate_delegation_error( &mut self, err: ErrorGuaranteed, span: Span, ) -> DelegationResults<'hir>

Source

fn generate_header_error(&self) -> FnHeader

Source

fn mk_expr(&mut self, kind: ExprKind<'hir>, span: Span) -> Expr<'hir>

Source§

impl<'hir> LoweringContext<'_, 'hir>

Source

fn lower_exprs(&mut self, exprs: &[AstP<Expr>]) -> &'hir [Expr<'hir>]

Source

pub(crate) fn lower_expr(&mut self, e: &Expr) -> &'hir Expr<'hir>

Source

pub(crate) fn lower_expr_mut(&mut self, e: &Expr) -> Expr<'hir>

Source

fn lower_unop(&mut self, u: UnOp) -> UnOp

Source

fn lower_binop(&mut self, b: BinOp) -> BinOp

Source

fn lower_legacy_const_generics( &mut self, f: Expr, args: ThinVec<AstP<Expr>>, legacy_args_idx: &[usize], ) -> ExprKind<'hir>

Source

fn lower_expr_if( &mut self, cond: &Expr, then: &Block, else_opt: Option<&Expr>, ) -> ExprKind<'hir>

Source

fn lower_cond(&mut self, cond: &Expr) -> &'hir Expr<'hir>

Source

fn lower_expr_while_in_loop_scope( &mut self, span: Span, cond: &Expr, body: &Block, opt_label: Option<Label>, ) -> ExprKind<'hir>

Source

fn lower_expr_try_block(&mut self, body: &Block) -> ExprKind<'hir>

Desugar try { <stmts>; <expr> } into { <stmts>; ::std::ops::Try::from_output(<expr>) }, try { <stmts>; } into { <stmts>; ::std::ops::Try::from_output(()) } and save the block id to use it as a break target for desugaring of the ? operator.

Source

fn wrap_in_try_constructor( &mut self, lang_item: LangItem, method_span: Span, expr: &'hir Expr<'hir>, overall_span: Span, ) -> &'hir Expr<'hir>

Source

fn lower_arm(&mut self, arm: &Arm) -> Arm<'hir>

Source

pub(crate) fn make_desugared_coroutine_expr( &mut self, capture_clause: CaptureBy, closure_node_id: NodeId, return_ty: Option<FnRetTy<'hir>>, fn_decl_span: Span, span: Span, desugaring_kind: CoroutineDesugaring, coroutine_source: CoroutineSource, body: impl FnOnce(&mut Self) -> Expr<'hir>, ) -> ExprKind<'hir>

Lower/desugar a coroutine construct.

In particular, this creates the correct async resume argument and _task_context.

This results in:

static move? |<_task_context?>| -> <return_ty> {
    <body>
}
Source

pub(crate) fn maybe_forward_track_caller( &mut self, span: Span, outer_hir_id: HirId, inner_hir_id: HirId, )

Forwards a possible #[track_caller] annotation from outer_hir_id to inner_hir_id in case the async_fn_track_caller feature is enabled.

Source

fn lower_expr_await( &mut self, await_kw_span: Span, expr: &Expr, ) -> ExprKind<'hir>

Desugar <expr>.await into:

match ::std::future::IntoFuture::into_future(<expr>) {
    mut __awaitee => loop {
        match unsafe { ::std::future::Future::poll(
            <::std::pin::Pin>::new_unchecked(&mut __awaitee),
            ::std::future::get_context(task_context),
        ) } {
            ::std::task::Poll::Ready(result) => break result,
            ::std::task::Poll::Pending => {}
        }
        task_context = yield ();
    }
}
Source

fn make_lowered_await( &mut self, await_kw_span: Span, expr: &'hir Expr<'hir>, await_kind: FutureKind, ) -> ExprKind<'hir>

Takes an expr that has already been lowered and generates a desugared await loop around it

Source

fn lower_expr_closure( &mut self, binder: &ClosureBinder, capture_clause: CaptureBy, closure_id: NodeId, closure_hir_id: HirId, constness: Const, movability: Movability, decl: &FnDecl, body: &Expr, fn_decl_span: Span, fn_arg_span: Span, ) -> ExprKind<'hir>

Source

fn closure_movability_for_fn( &mut self, decl: &FnDecl, fn_decl_span: Span, coroutine_kind: Option<CoroutineKind>, movability: Movability, ) -> ClosureKind

Source

fn lower_closure_binder<'c>( &mut self, binder: &'c ClosureBinder, ) -> (ClosureBinder, &'c [GenericParam])

Source

fn lower_expr_coroutine_closure( &mut self, binder: &ClosureBinder, capture_clause: CaptureBy, closure_id: NodeId, closure_hir_id: HirId, coroutine_kind: CoroutineKind, decl: &FnDecl, body: &Expr, fn_decl_span: Span, fn_arg_span: Span, ) -> ExprKind<'hir>

Source

fn lower_expr_assign( &mut self, lhs: &Expr, rhs: &Expr, eq_sign_span: Span, whole_span: Span, ) -> ExprKind<'hir>

Destructure the LHS of complex assignments. For instance, lower (a, b) = t to { let (lhs1, lhs2) = t; a = lhs1; b = lhs2; }.

Source

fn extract_tuple_struct_path<'a>( &mut self, expr: &'a Expr, ) -> Option<(&'a Option<AstP<QSelf>>, &'a Path)>

If the given expression is a path to a tuple struct, returns that path. It is not a complete check, but just tries to reject most paths early if they are not tuple structs. Type checking will take care of the full validation later.

Source

fn extract_unit_struct_path<'a>( &mut self, expr: &'a Expr, ) -> Option<(&'a Option<AstP<QSelf>>, &'a Path)>

If the given expression is a path to a unit struct, returns that path. It is not a complete check, but just tries to reject most paths early if they are not unit structs. Type checking will take care of the full validation later.

Source

fn destructure_assign( &mut self, lhs: &Expr, eq_sign_span: Span, assignments: &mut Vec<Stmt<'hir>>, ) -> &'hir Pat<'hir>

Convert the LHS of a destructuring assignment to a pattern. Each sub-assignment is recorded in assignments.

Source

fn destructure_assign_mut( &mut self, lhs: &Expr, eq_sign_span: Span, assignments: &mut Vec<Stmt<'hir>>, ) -> Pat<'hir>

Source

fn destructure_sequence( &mut self, elements: &[AstP<Expr>], ctx: &str, eq_sign_span: Span, assignments: &mut Vec<Stmt<'hir>>, ) -> (&'hir [Pat<'hir>], Option<(usize, Span)>)

Destructure a sequence of expressions occurring on the LHS of an assignment. Such a sequence occurs in a tuple (struct)/slice. Return a sequence of corresponding patterns, and the index and the span of .. if it exists. Each sub-assignment is recorded in assignments.

Source

fn lower_expr_range_closed( &mut self, span: Span, e1: &Expr, e2: &Expr, ) -> ExprKind<'hir>

Desugar <start>..=<end> into std::ops::RangeInclusive::new(<start>, <end>).

Source

fn lower_expr_range( &mut self, span: Span, e1: Option<&Expr>, e2: Option<&Expr>, lims: RangeLimits, ) -> ExprKind<'hir>

Source

fn lower_label( &mut self, opt_label: Option<Label>, dest_id: NodeId, dest_hir_id: HirId, ) -> Option<Label>

Source

fn lower_loop_destination( &mut self, destination: Option<(NodeId, Label)>, ) -> Destination

Source

fn lower_jump_destination( &mut self, id: NodeId, opt_label: Option<Label>, ) -> Destination

Source

fn with_catch_scope<T>( &mut self, catch_id: HirId, f: impl FnOnce(&mut Self) -> T, ) -> T

Source

fn with_loop_scope<T>( &mut self, loop_id: HirId, f: impl FnOnce(&mut Self) -> T, ) -> T

Source

fn with_loop_condition_scope<T>(&mut self, f: impl FnOnce(&mut Self) -> T) -> T

Source

fn lower_expr_field(&mut self, f: &ExprField) -> ExprField<'hir>

Source

fn lower_expr_yield( &mut self, span: Span, opt_expr: Option<&Expr>, ) -> ExprKind<'hir>

Source

fn lower_expr_for( &mut self, e: &Expr, pat: &Pat, head: &Expr, body: &Block, opt_label: Option<Label>, loop_kind: ForLoopKind, ) -> Expr<'hir>

Desugar ExprForLoop from: [opt_ident]: for <pat> in <head> <body> into:

{
    let result = match IntoIterator::into_iter(<head>) {
        mut iter => {
            [opt_ident]: loop {
                match Iterator::next(&mut iter) {
                    None => break,
                    Some(<pat>) => <body>,
                };
            }
        }
    };
    result
}
Source

fn lower_expr_try(&mut self, span: Span, sub_expr: &Expr) -> ExprKind<'hir>

Desugar ExprKind::Try from: <expr>? into:

match Try::branch(<expr>) {
    ControlFlow::Continue(val) => #[allow(unreachable_code)] val,,
    ControlFlow::Break(residual) =>
        #[allow(unreachable_code)]
        // If there is an enclosing `try {...}`:
        break 'catch_target Try::from_residual(residual),
        // Otherwise:
        return Try::from_residual(residual),
}
Source

fn lower_expr_yeet( &mut self, span: Span, sub_expr: Option<&Expr>, ) -> ExprKind<'hir>

Desugar ExprKind::Yeet from: do yeet <expr> into:

// If there is an enclosing `try {...}`:
break 'catch_target FromResidual::from_residual(Yeet(residual));
// Otherwise:
return FromResidual::from_residual(Yeet(residual));

But to simplify this, there’s a from_yeet lang item function which handles the combined FromResidual::from_residual(Yeet(residual)).

Source

pub(crate) fn expr_drop_temps( &mut self, span: Span, expr: &'hir Expr<'hir>, ) -> &'hir Expr<'hir>

Wrap the given expr in a terminating scope using hir::ExprKind::DropTemps.

In terms of drop order, it has the same effect as wrapping expr in { let _t = $expr; _t } but should provide better compile-time performance.

The drop order can be important in e.g. if expr { .. }.

Source

pub(crate) fn expr_drop_temps_mut( &mut self, span: Span, expr: &'hir Expr<'hir>, ) -> Expr<'hir>

Source

pub(crate) fn expr_match( &mut self, span: Span, arg: &'hir Expr<'hir>, arms: &'hir [Arm<'hir>], source: MatchSource, ) -> Expr<'hir>

Source

fn expr_break(&mut self, span: Span) -> Expr<'hir>

Source

fn expr_break_alloc(&mut self, span: Span) -> &'hir Expr<'hir>

Source

fn expr_mut_addr_of(&mut self, span: Span, e: &'hir Expr<'hir>) -> Expr<'hir>

Source

fn expr_unit(&mut self, sp: Span) -> &'hir Expr<'hir>

Source

pub(crate) fn expr_usize(&mut self, sp: Span, value: usize) -> Expr<'hir>

Source

pub(crate) fn expr_u32(&mut self, sp: Span, value: u32) -> Expr<'hir>

Source

pub(crate) fn expr_char(&mut self, sp: Span, value: char) -> Expr<'hir>

Source

pub(crate) fn expr_str(&mut self, sp: Span, value: Symbol) -> Expr<'hir>

Source

pub(crate) fn expr_call_mut( &mut self, span: Span, e: &'hir Expr<'hir>, args: &'hir [Expr<'hir>], ) -> Expr<'hir>

Source

pub(crate) fn expr_call( &mut self, span: Span, e: &'hir Expr<'hir>, args: &'hir [Expr<'hir>], ) -> &'hir Expr<'hir>

Source

fn expr_call_lang_item_fn_mut( &mut self, span: Span, lang_item: LangItem, args: &'hir [Expr<'hir>], ) -> Expr<'hir>

Source

fn expr_call_lang_item_fn( &mut self, span: Span, lang_item: LangItem, args: &'hir [Expr<'hir>], ) -> &'hir Expr<'hir>

Source

fn expr_lang_item_path(&mut self, span: Span, lang_item: LangItem) -> Expr<'hir>

Source

pub(crate) fn expr_lang_item_type_relative( &mut self, span: Span, lang_item: LangItem, name: Symbol, ) -> Expr<'hir>

<LangItem>::name

Source

pub(crate) fn expr_ident( &mut self, sp: Span, ident: Ident, binding: HirId, ) -> &'hir Expr<'hir>

Source

pub(crate) fn expr_ident_mut( &mut self, span: Span, ident: Ident, binding: HirId, ) -> Expr<'hir>

Source

fn expr_unsafe(&mut self, expr: &'hir Expr<'hir>) -> Expr<'hir>

Source

fn expr_block_empty(&mut self, span: Span) -> &'hir Expr<'hir>

Source

pub(crate) fn expr_block(&mut self, b: &'hir Block<'hir>) -> Expr<'hir>

Source

pub(crate) fn expr_array_ref( &mut self, span: Span, elements: &'hir [Expr<'hir>], ) -> Expr<'hir>

Source

pub(crate) fn expr(&mut self, span: Span, kind: ExprKind<'hir>) -> Expr<'hir>

Source

pub(crate) fn expr_field( &mut self, ident: Ident, expr: &'hir Expr<'hir>, span: Span, ) -> ExprField<'hir>

Source

pub(crate) fn arm( &mut self, pat: &'hir Pat<'hir>, expr: &'hir Expr<'hir>, ) -> Arm<'hir>

Source§

impl<'hir> LoweringContext<'_, 'hir>

Source

pub(crate) fn lower_format_args( &mut self, sp: Span, fmt: &FormatArgs, ) -> ExprKind<'hir>

Source

fn try_inline_lit(&self, lit: Lit) -> Option<Symbol>

Try to convert a literal into an interned string

Source

fn int_ty_max(&self, int_ty: IntTy) -> u128

Get the maximum value of int_ty. It is platform-dependent due to the byte size of isize

Source

fn uint_ty_max(&self, uint_ty: UintTy) -> u128

Get the maximum value of uint_ty. It is platform-dependent due to the byte size of usize

Source

fn inline_literals<'fmt>( &self, fmt: Cow<'fmt, FormatArgs>, ) -> Cow<'fmt, FormatArgs>

Inline literals into the format string.

Turns

format_args!("Hello, {}! {} {}", "World", 123, x)

into

format_args!("Hello, World! 123 {}", x).

Source§

impl<'hir> LoweringContext<'_, 'hir>

Source

pub(crate) fn lower_mod( &mut self, items: &[P<Item>], spans: &ModSpans, ) -> &'hir Mod<'hir>

Source

pub(crate) fn lower_item_ref(&mut self, i: &Item) -> SmallVec<[ItemId; 1]>

Source

fn lower_item_id_use_tree( &mut self, tree: &UseTree, vec: &mut SmallVec<[ItemId; 1]>, )

Source

fn lower_item(&mut self, i: &Item) -> &'hir Item<'hir>

Source

fn lower_item_kind( &mut self, span: Span, id: NodeId, hir_id: HirId, ident: &mut Ident, attrs: &'hir [Attribute], vis_span: Span, i: &ItemKind, ) -> ItemKind<'hir>

Source

fn lower_const_item( &mut self, ty: &Ty, span: Span, body: Option<&Expr>, impl_trait_position: ImplTraitPosition, ) -> (&'hir Ty<'hir>, BodyId)

Source

fn lower_use_tree( &mut self, tree: &UseTree, prefix: &Path, id: NodeId, vis_span: Span, ident: &mut Ident, attrs: &'hir [Attribute], ) -> ItemKind<'hir>

Source

fn lower_assoc_item( &mut self, item: &AssocItem, ctxt: AssocCtxt, parent_hir: &'hir OwnerInfo<'hir>, ) -> OwnerNode<'hir>

Source

fn lower_foreign_item(&mut self, i: &ForeignItem) -> &'hir ForeignItem<'hir>

Source

fn lower_foreign_item_ref(&mut self, i: &ForeignItem) -> ForeignItemRef

Source

fn lower_variant(&mut self, v: &Variant) -> Variant<'hir>

Source

fn lower_variant_data( &mut self, parent_id: HirId, vdata: &VariantData, ) -> VariantData<'hir>

Source

pub(crate) fn lower_field_def( &mut self, (index, f): (usize, &FieldDef), ) -> FieldDef<'hir>

Source

fn lower_trait_item(&mut self, i: &AssocItem) -> &'hir TraitItem<'hir>

Source

fn lower_trait_item_ref(&mut self, i: &AssocItem) -> TraitItemRef

Source

pub(crate) fn expr_err( &mut self, span: Span, guar: ErrorGuaranteed, ) -> Expr<'hir>

Construct ExprKind::Err for the given span.

Source

fn lower_impl_item(&mut self, i: &AssocItem) -> &'hir ImplItem<'hir>

Source

fn lower_impl_item_ref(&mut self, i: &AssocItem) -> ImplItemRef

Source

fn lower_defaultness( &self, d: Defaultness, has_value: bool, ) -> (Defaultness, Option<Span>)

Source

fn record_body( &mut self, params: &'hir [Param<'hir>], value: Expr<'hir>, ) -> BodyId

Source

pub(crate) fn lower_body( &mut self, f: impl FnOnce(&mut Self) -> (&'hir [Param<'hir>], Expr<'hir>), ) -> BodyId

Source

fn lower_param(&mut self, param: &Param) -> Param<'hir>

Source

pub(crate) fn lower_fn_body( &mut self, decl: &FnDecl, body: impl FnOnce(&mut Self) -> Expr<'hir>, ) -> BodyId

Source

fn lower_fn_body_block( &mut self, span: Span, decl: &FnDecl, body: Option<&Block>, ) -> BodyId

Source

fn lower_block_expr_opt( &mut self, span: Span, block: Option<&Block>, ) -> Expr<'hir>

Source

pub(crate) fn lower_const_body( &mut self, span: Span, expr: Option<&Expr>, ) -> BodyId

Source

fn lower_maybe_coroutine_body( &mut self, fn_decl_span: Span, span: Span, fn_id: HirId, decl: &FnDecl, coroutine_kind: Option<CoroutineKind>, body: Option<&Block>, ) -> BodyId

Takes what may be the body of an async fn or a gen fn and wraps it in an async {} or gen {} block as appropriate.

Source

pub(crate) fn lower_coroutine_body_with_moved_arguments( &mut self, decl: &FnDecl, lower_body: impl FnOnce(&mut LoweringContext<'_, 'hir>) -> Expr<'hir>, fn_decl_span: Span, body_span: Span, coroutine_kind: CoroutineKind, coroutine_source: CoroutineSource, ) -> (&'hir [Param<'hir>], Expr<'hir>)

Lowers a desugared coroutine body after moving all of the arguments into the body. This is to make sure that the future actually owns the arguments that are passed to the function, and to ensure things like drop order are stable.

Source

fn lower_method_sig( &mut self, generics: &Generics, sig: &FnSig, id: NodeId, kind: FnDeclKind, coroutine_kind: Option<CoroutineKind>, ) -> (&'hir Generics<'hir>, FnSig<'hir>)

Source

pub(crate) fn lower_fn_header( &mut self, h: FnHeader, default_safety: Safety, ) -> FnHeader

Source

pub(crate) fn lower_abi(&mut self, abi: StrLit) -> Abi

Source

pub(crate) fn lower_extern(&mut self, ext: Extern) -> Abi

Source

fn error_on_invalid_abi(&self, abi: StrLit, err: AbiUnsupported)

Source

pub(crate) fn lower_constness(&mut self, c: Const) -> Constness

Source

pub(crate) fn lower_safety(&mut self, s: Safety, default: Safety) -> Safety

Source

fn lower_generics<T>( &mut self, generics: &Generics, parent_node_id: NodeId, itctx: ImplTraitContext, f: impl FnOnce(&mut Self) -> T, ) -> (&'hir Generics<'hir>, T)

Return the pair of the lowered generics as hir::Generics and the evaluation of f with the carried impl trait definitions and bounds.

Source

pub(crate) fn lower_generic_bound_predicate( &mut self, ident: Ident, id: NodeId, kind: &GenericParamKind, bounds: &[GenericBound], colon_span: Option<Span>, parent_span: Span, itctx: ImplTraitContext, origin: PredicateOrigin, ) -> Option<WherePredicate<'hir>>

Source

fn lower_where_predicate( &mut self, pred: &WherePredicate, ) -> WherePredicate<'hir>

Source§

impl<'a, 'hir> LoweringContext<'a, 'hir>

Source

pub(crate) fn lower_pat(&mut self, pattern: &Pat) -> &'hir Pat<'hir>

Source

fn lower_pat_mut(&mut self, pattern: &Pat) -> Pat<'hir>

Source

fn lower_pat_tuple( &mut self, pats: &[P<Pat>], ctx: &str, ) -> (&'hir [Pat<'hir>], DotDotPos)

Source

fn lower_pat_slice(&mut self, pats: &[P<Pat>]) -> PatKind<'hir>

Lower a slice pattern of form [pat_0, ..., pat_n] into hir::PatKind::Slice(before, slice, after).

When encountering ($binding_mode $ident @)? .. (slice), this is interpreted as a sub-slice pattern semantically. Patterns that follow, which are not like slice – or an error occurs, are in after.

Source

fn lower_pat_ident( &mut self, p: &Pat, annotation: BindingMode, ident: Ident, hir_id: HirId, lower_sub: impl FnOnce(&mut Self) -> Option<&'hir Pat<'hir>>, ) -> PatKind<'hir>

Source

fn pat_wild_with_node_id_of( &mut self, p: &Pat, hir_id: HirId, ) -> &'hir Pat<'hir>

Source

fn pat_with_node_id_of( &mut self, p: &Pat, kind: PatKind<'hir>, hir_id: HirId, ) -> Pat<'hir>

Construct a Pat with the HirId of p.id already lowered.

Source

pub(crate) fn ban_extra_rest_pat(&self, sp: Span, prev_sp: Span, ctx: &str)

Emit a friendly error for extra .. patterns in a tuple/tuple struct/slice pattern.

Source

fn ban_illegal_rest_pat(&self, sp: Span) -> PatKind<'hir>

Used to ban the .. pattern in places it shouldn’t be semantically.

Source

fn lower_range_end(&mut self, e: &RangeEnd, has_end: bool) -> RangeEnd

Source

fn lower_expr_within_pat( &mut self, expr: &Expr, allow_paths: bool, ) -> &'hir Expr<'hir>

Matches '-' lit | lit (cf. parser::Parser::parse_literal_maybe_minus), or paths for ranges.

Source§

impl<'a, 'hir> LoweringContext<'a, 'hir>

Source

pub(crate) fn lower_qpath( &mut self, id: NodeId, qself: &Option<P<QSelf>>, p: &Path, param_mode: ParamMode, allow_return_type_notation: AllowReturnTypeNotation, itctx: ImplTraitContext, modifiers: Option<TraitBoundModifiers>, ) -> QPath<'hir>

Source

pub(crate) fn lower_use_path( &mut self, res: SmallVec<[Res; 3]>, p: &Path, param_mode: ParamMode, ) -> &'hir UsePath<'hir>

Source

pub(crate) fn lower_path_segment( &mut self, path_span: Span, segment: &PathSegment, param_mode: ParamMode, generic_args_mode: GenericArgsMode, itctx: ImplTraitContext, bound_modifier_allowed_features: Option<Lrc<[Symbol]>>, ) -> PathSegment<'hir>

Source

fn maybe_insert_elided_lifetimes_in_path( &mut self, path_span: Span, segment_id: NodeId, segment_ident_span: Span, generic_args: &mut GenericArgsCtor<'hir>, )

Source

pub(crate) fn lower_angle_bracketed_parameter_data( &mut self, data: &AngleBracketedArgs, param_mode: ParamMode, itctx: ImplTraitContext, ) -> (GenericArgsCtor<'hir>, bool)

Source

fn lower_parenthesized_parameter_data( &mut self, data: &ParenthesizedArgs, itctx: ImplTraitContext, bound_modifier_allowed_features: Option<Lrc<[Symbol]>>, ) -> (GenericArgsCtor<'hir>, bool)

Source

pub(crate) fn assoc_ty_binding( &mut self, assoc_ty_name: Symbol, span: Span, ty: &'hir Ty<'hir>, ) -> AssocItemConstraint<'hir>

An associated type binding (i.e., associated type equality constraint).

Source

fn map_trait_to_async_trait(&self, def_id: DefId) -> Option<DefId>

When a bound is annotated with async, it signals to lowering that the trait that the bound refers to should be mapped to the “async” flavor of the trait.

This only needs to be done until we unify AsyncFn and Fn traits into one that is generic over asyncness, if that’s ever possible, or modify the lowering of async Fn() bounds to desugar to another trait like LendingFn.

Source§

impl<'a, 'hir> LoweringContext<'a, 'hir>

Source

pub(crate) fn new( tcx: TyCtxt<'hir>, resolver: &'a mut ResolverAstLowering, ) -> Self

Source

pub(crate) fn dcx(&self) -> DiagCtxtHandle<'hir>

Source§

impl<'a, 'hir> LoweringContext<'a, 'hir>

Source

pub(crate) fn create_def( &mut self, parent: LocalDefId, node_id: NodeId, name: Symbol, def_kind: DefKind, span: Span, ) -> LocalDefId

Source

pub(crate) fn next_node_id(&mut self) -> NodeId

Source

pub(crate) fn opt_local_def_id(&self, node: NodeId) -> Option<LocalDefId>

Given the id of some node in the AST, finds the LocalDefId associated with it by the name resolver (if any).

Source

pub(crate) fn local_def_id(&self, node: NodeId) -> LocalDefId

Source

pub(crate) fn with_hir_id_owner( &mut self, owner: NodeId, f: impl FnOnce(&mut Self) -> OwnerNode<'hir>, )

Freshen the LoweringContext and ready it to lower a nested item. The lowered item is registered into self.children.

This function sets up HirId lowering infrastructure, and stashes the shared mutable state to avoid pollution by the closure.

Source

pub(crate) fn with_def_id_parent<T>( &mut self, parent: LocalDefId, f: impl FnOnce(&mut Self) -> T, ) -> T

Source

pub(crate) fn make_owner_info( &mut self, node: OwnerNode<'hir>, ) -> &'hir OwnerInfo<'hir>

Source

pub(crate) fn lower_node_id(&mut self, ast_node_id: NodeId) -> HirId

This method allocates a new HirId for the given NodeId. Take care not to call this method if the resulting HirId is then not actually used in the HIR, as that would trigger an assertion in the HirIdValidator later on, which makes sure that all NodeIds got mapped properly. Calling the method twice with the same NodeId is also forbidden.

Source

pub(crate) fn next_id(&mut self) -> HirId

Generate a new HirId without a backing NodeId.

Source

pub(crate) fn lower_res(&mut self, res: Res<NodeId>) -> Res

Source

pub(crate) fn expect_full_res(&mut self, id: NodeId) -> Res<NodeId>

Source

pub(crate) fn lower_import_res( &mut self, id: NodeId, span: Span, ) -> SmallVec<[Res; 3]>

Source

pub(crate) fn make_lang_item_qpath( &mut self, lang_item: LangItem, span: Span, args: Option<&'hir GenericArgs<'hir>>, ) -> QPath<'hir>

Source

pub(crate) fn make_lang_item_path( &mut self, lang_item: LangItem, span: Span, args: Option<&'hir GenericArgs<'hir>>, ) -> &'hir Path<'hir>

Source

pub(crate) fn mark_span_with_reason( &self, reason: DesugaringKind, span: Span, allow_internal_unstable: Option<Lrc<[Symbol]>>, ) -> Span

Reuses the span but adds information like the kind of the desugaring and features that are allowed inside this span.

Source

pub(crate) fn lower_span(&self, span: Span) -> Span

Intercept all spans entering HIR. Mark a span as relative to the current owning item.

Source

pub(crate) fn lower_ident(&self, ident: Ident) -> Ident

Source

pub(crate) fn lifetime_res_to_generic_param( &mut self, ident: Ident, node_id: NodeId, res: LifetimeRes, source: GenericParamSource, ) -> Option<GenericParam<'hir>>

Converts a lifetime into a new generic parameter.

Source

pub(crate) fn lower_lifetime_binder( &mut self, binder: NodeId, generic_params: &[GenericParam], ) -> &'hir [GenericParam<'hir>]

Lowers a lifetime binder that defines generic_params, returning the corresponding HIR nodes. The returned list includes any “extra” lifetime parameters that were added by the name resolver owing to lifetime elision; this also populates the resolver’s node-id->def-id map, so that later calls to opt_node_id_to_def_id that refer to these extra lifetime parameters will be successful.

Source

pub(crate) fn with_dyn_type_scope<T>( &mut self, in_scope: bool, f: impl FnOnce(&mut Self) -> T, ) -> T

Source

pub(crate) fn with_new_scopes<T>( &mut self, scope_span: Span, f: impl FnOnce(&mut Self) -> T, ) -> T

Source

pub(crate) fn lower_attrs( &mut self, id: HirId, attrs: &[Attribute], ) -> &'hir [Attribute]

Source

pub(crate) fn lower_attr(&self, attr: &Attribute) -> Attribute

Source

pub(crate) fn alias_attrs(&mut self, id: HirId, target_id: HirId)

Source

pub(crate) fn lower_attr_args(&self, args: &AttrArgs) -> AttrArgs

Source

pub(crate) fn lower_delim_args(&self, args: &DelimArgs) -> DelimArgs

Source

pub(crate) fn lower_assoc_item_constraint( &mut self, constraint: &AssocItemConstraint, itctx: ImplTraitContext, ) -> AssocItemConstraint<'hir>

Lower an associated item constraint.

Source

pub(crate) fn emit_bad_parenthesized_trait_in_assoc_ty( &self, data: &ParenthesizedArgs, )

Source

pub(crate) fn lower_generic_arg( &mut self, arg: &GenericArg, itctx: ImplTraitContext, ) -> GenericArg<'hir>

Source

pub(crate) fn lower_ty( &mut self, t: &Ty, itctx: ImplTraitContext, ) -> &'hir Ty<'hir>

Source

pub(crate) fn lower_path_ty( &mut self, t: &Ty, qself: &Option<P<QSelf>>, path: &Path, param_mode: ParamMode, itctx: ImplTraitContext, ) -> Ty<'hir>

Source

pub(crate) fn ty(&mut self, span: Span, kind: TyKind<'hir>) -> Ty<'hir>

Source

pub(crate) fn ty_tup(&mut self, span: Span, tys: &'hir [Ty<'hir>]) -> Ty<'hir>

Source

pub(crate) fn lower_ty_direct( &mut self, t: &Ty, itctx: ImplTraitContext, ) -> Ty<'hir>

Source

pub(crate) fn lower_opaque_impl_trait( &mut self, span: Span, origin: OpaqueTyOrigin<LocalDefId>, opaque_ty_node_id: NodeId, bounds: &GenericBounds, itctx: ImplTraitContext, ) -> TyKind<'hir>

Lowers a ReturnPositionOpaqueTy (-> impl Trait) or a TypeAliasesOpaqueTy (type F = impl Trait): this creates the associated Opaque Type (TAIT) definition and then returns a HIR type that references the TAIT.

Given a function definition like:

use std::fmt::Debug;

fn test<'a, T: Debug>(x: &'a T) -> impl Debug + 'a {
    x
}

we will create a TAIT definition in the HIR like

type TestReturn<'a, T, 'x> = impl Debug + 'x

and return a type like TestReturn<'static, T, 'a>, so that the function looks like:

fn test<'a, T: Debug>(x: &'a T) -> TestReturn<'static, T, 'a>

Note the subtlety around type parameters! The new TAIT, TestReturn, inherits all the type parameters from the function test (this is implemented in the query layer, they aren’t added explicitly in the HIR). But this includes all the lifetimes, and we only want to capture the lifetimes that are referenced in the bounds. Therefore, we add extra lifetime parameters for the lifetimes that get captured ('x, in our example above) and reference those.

Source

pub(crate) fn lower_opaque_inner( &mut self, opaque_ty_node_id: NodeId, origin: OpaqueTyOrigin<LocalDefId>, opaque_ty_span: Span, lower_item_bounds: impl FnOnce(&mut Self) -> &'hir [GenericBound<'hir>], ) -> TyKind<'hir>

Source

pub(crate) fn lower_precise_capturing_args( &mut self, precise_capturing_args: &[PreciseCapturingArg], ) -> &'hir [PreciseCapturingArg<'hir>]

Source

pub(crate) fn lower_fn_params_to_names( &mut self, decl: &FnDecl, ) -> &'hir [Ident]

Source

pub(crate) fn lower_fn_decl( &mut self, decl: &FnDecl, fn_node_id: NodeId, fn_span: Span, kind: FnDeclKind, coro: Option<CoroutineKind>, ) -> &'hir FnDecl<'hir>

Lowers a function declaration.

decl: the unlowered (AST) function declaration.

fn_node_id: impl Trait arguments are lowered into generic parameters on the given NodeId.

transform_return_type: if Some, applies some conversion to the return type, such as is needed for async fn and gen fn. See CoroutineKind for more details.

Source

pub(crate) fn lower_coroutine_fn_ret_ty( &mut self, output: &FnRetTy, fn_def_id: LocalDefId, coro: CoroutineKind, fn_kind: FnDeclKind, fn_span: Span, ) -> FnRetTy<'hir>

Source

pub(crate) fn lower_coroutine_fn_output_type_to_bound( &mut self, output: &FnRetTy, coro: CoroutineKind, opaque_ty_span: Span, itctx: ImplTraitContext, ) -> GenericBound<'hir>

Transforms -> T into Future<Output = T>.

Source

pub(crate) fn lower_param_bound( &mut self, tpb: &GenericBound, itctx: ImplTraitContext, ) -> GenericBound<'hir>

Source

pub(crate) fn lower_lifetime(&mut self, l: &Lifetime) -> &'hir Lifetime

Source

pub(crate) fn new_named_lifetime_with_res( &mut self, id: NodeId, ident: Ident, res: LifetimeRes, ) -> &'hir Lifetime

Source

pub(crate) fn new_named_lifetime( &mut self, id: NodeId, new_id: NodeId, ident: Ident, ) -> &'hir Lifetime

Source

pub(crate) fn lower_generic_params_mut<'s>( &'s mut self, params: &'s [GenericParam], source: GenericParamSource, ) -> impl Iterator<Item = GenericParam<'hir>> + Captures<'a> + Captures<'s>

Source

pub(crate) fn lower_generic_params( &mut self, params: &[GenericParam], source: GenericParamSource, ) -> &'hir [GenericParam<'hir>]

Source

pub(crate) fn lower_generic_param( &mut self, param: &GenericParam, source: GenericParamSource, ) -> GenericParam<'hir>

Source

pub(crate) fn lower_generic_param_kind( &mut self, param: &GenericParam, source: GenericParamSource, ) -> (ParamName, GenericParamKind<'hir>)

Source

pub(crate) fn lower_trait_ref( &mut self, modifiers: TraitBoundModifiers, p: &TraitRef, itctx: ImplTraitContext, ) -> TraitRef<'hir>

Source

pub(crate) fn lower_poly_trait_ref( &mut self, p: &PolyTraitRef, itctx: ImplTraitContext, ) -> PolyTraitRef<'hir>

Source

pub(crate) fn lower_mt( &mut self, mt: &MutTy, itctx: ImplTraitContext, ) -> MutTy<'hir>

Source

pub(crate) fn lower_param_bounds( &mut self, bounds: &[GenericBound], itctx: ImplTraitContext, ) -> GenericBounds<'hir>

Source

pub(crate) fn lower_param_bounds_mut<'s>( &'s mut self, bounds: &'s [GenericBound], itctx: ImplTraitContext, ) -> impl Iterator<Item = GenericBound<'hir>> + Captures<'s> + Captures<'a>

Source

pub(crate) fn lower_universal_param_and_bounds( &mut self, node_id: NodeId, span: Span, ident: Ident, bounds: &[GenericBound], ) -> (GenericParam<'hir>, Option<WherePredicate<'hir>>, TyKind<'hir>)

Source

pub(crate) fn lower_block_expr(&mut self, b: &Block) -> Expr<'hir>

Lowers a block directly to an expression, presuming that it has no attributes and is not targeted by a break.

Source

pub(crate) fn lower_array_length(&mut self, c: &AnonConst) -> ArrayLen<'hir>

Source

pub(crate) fn lower_const_path_to_const_arg( &mut self, path: &Path, res: Res<NodeId>, ty_id: NodeId, span: Span, ) -> &'hir ConstArg<'hir>

Used when lowering a type argument that turned out to actually be a const argument.

Only use for that purpose since otherwise it will create a duplicate def.

Source

pub(crate) fn lower_anon_const_to_const_arg( &mut self, anon: &AnonConst, ) -> &'hir ConstArg<'hir>

See hir::ConstArg for when to use this function vs Self::lower_anon_const_to_anon_const.

Source

pub(crate) fn lower_anon_const_to_const_arg_direct( &mut self, anon: &AnonConst, ) -> ConstArg<'hir>

Source

pub(crate) fn lower_anon_const_to_anon_const( &mut self, c: &AnonConst, ) -> &'hir AnonConst

See hir::ConstArg for when to use this function vs Self::lower_anon_const_to_const_arg.

Source

pub(crate) fn lower_unsafe_source(&mut self, u: UnsafeSource) -> UnsafeSource

Source

pub(crate) fn lower_trait_bound_modifiers( &mut self, modifiers: TraitBoundModifiers, ) -> TraitBoundModifiers

Source

pub(crate) fn stmt(&mut self, span: Span, kind: StmtKind<'hir>) -> Stmt<'hir>

Source

pub(crate) fn stmt_expr(&mut self, span: Span, expr: Expr<'hir>) -> Stmt<'hir>

Source

pub(crate) fn stmt_let_pat( &mut self, attrs: Option<&'hir [Attribute]>, span: Span, init: Option<&'hir Expr<'hir>>, pat: &'hir Pat<'hir>, source: LocalSource, ) -> Stmt<'hir>

Source

pub(crate) fn block_expr(&mut self, expr: &'hir Expr<'hir>) -> &'hir Block<'hir>

Source

pub(crate) fn block_all( &mut self, span: Span, stmts: &'hir [Stmt<'hir>], expr: Option<&'hir Expr<'hir>>, ) -> &'hir Block<'hir>

Source

pub(crate) fn pat_cf_continue( &mut self, span: Span, pat: &'hir Pat<'hir>, ) -> &'hir Pat<'hir>

Source

pub(crate) fn pat_cf_break( &mut self, span: Span, pat: &'hir Pat<'hir>, ) -> &'hir Pat<'hir>

Source

pub(crate) fn pat_some( &mut self, span: Span, pat: &'hir Pat<'hir>, ) -> &'hir Pat<'hir>

Source

pub(crate) fn pat_none(&mut self, span: Span) -> &'hir Pat<'hir>

Source

pub(crate) fn single_pat_field( &mut self, span: Span, pat: &'hir Pat<'hir>, ) -> &'hir [PatField<'hir>]

Source

pub(crate) fn pat_lang_item_variant( &mut self, span: Span, lang_item: LangItem, fields: &'hir [PatField<'hir>], ) -> &'hir Pat<'hir>

Source

pub(crate) fn pat_ident( &mut self, span: Span, ident: Ident, ) -> (&'hir Pat<'hir>, HirId)

Source

pub(crate) fn pat_ident_mut( &mut self, span: Span, ident: Ident, ) -> (Pat<'hir>, HirId)

Source

pub(crate) fn pat_ident_binding_mode( &mut self, span: Span, ident: Ident, bm: BindingMode, ) -> (&'hir Pat<'hir>, HirId)

Source

pub(crate) fn pat_ident_binding_mode_mut( &mut self, span: Span, ident: Ident, bm: BindingMode, ) -> (Pat<'hir>, HirId)

Source

pub(crate) fn pat(&mut self, span: Span, kind: PatKind<'hir>) -> &'hir Pat<'hir>

Source

pub(crate) fn pat_without_dbm( &mut self, span: Span, kind: PatKind<'hir>, ) -> Pat<'hir>

Source

pub(crate) fn ty_path( &mut self, hir_id: HirId, span: Span, qpath: QPath<'hir>, ) -> Ty<'hir>

Source

pub(crate) fn elided_dyn_bound(&mut self, span: Span) -> &'hir Lifetime

Invoked to create the lifetime argument(s) for an elided trait object bound, like the bound in Box<dyn Debug>. This method is not invoked when the bound is written, even if it is written with '_ like in Box<dyn Debug + '_>. In those cases, lower_lifetime is invoked.

Auto Trait Implementations§

§

impl<'a, 'hir> !DynSend for LoweringContext<'a, 'hir>

§

impl<'a, 'hir> !DynSync for LoweringContext<'a, 'hir>

§

impl<'a, 'hir> Freeze for LoweringContext<'a, 'hir>

§

impl<'a, 'hir> !RefUnwindSafe for LoweringContext<'a, 'hir>

§

impl<'a, 'hir> !Send for LoweringContext<'a, 'hir>

§

impl<'a, 'hir> !Sync for LoweringContext<'a, 'hir>

§

impl<'a, 'hir> Unpin for LoweringContext<'a, 'hir>

§

impl<'a, 'hir> !UnwindSafe for LoweringContext<'a, 'hir>

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
Source§

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

Source§

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<_>>()).

Source§

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.
Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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,

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 376 bytes