Struct rustc_ast_lowering::LoweringContext [−][src]
pub(crate) struct LoweringContext<'a, 'hir: 'a> {Show 25 fields
sess: &'a Session,
resolver: &'a mut dyn ResolverAstLowering,
nt_to_tokenstream: NtToTokenstream,
arena: &'hir Arena<'hir>,
owners: IndexVec<LocalDefId, Option<OwnerInfo<'hir>>>,
bodies: IndexVec<ItemLocalId, Option<&'hir Body<'hir>>>,
attrs: BTreeMap<ItemLocalId, &'hir [Attribute]>,
generator_kind: Option<GeneratorKind>,
task_context: Option<HirId>,
current_item: Option<Span>,
catch_scope: Option<NodeId>,
loop_scope: Option<NodeId>,
is_in_loop_condition: bool,
is_in_trait_impl: bool,
is_in_dyn_type: bool,
anonymous_lifetime_mode: AnonymousLifetimeMode,
lifetimes_to_define: Vec<(Span, ParamName)>,
is_collecting_in_band_lifetimes: bool,
in_scope_lifetimes: Vec<ParamName>,
current_hir_id_owner: LocalDefId,
item_local_id_counter: ItemLocalId,
node_id_to_hir_id: IndexVec<NodeId, Option<HirId>>,
local_node_ids: Vec<NodeId>,
allow_try_trait: Option<Lrc<[Symbol]>>,
allow_gen_future: Option<Lrc<[Symbol]>>,
}
Fields
sess: &'a Session
Used to assign IDs to HIR nodes that do not directly correspond to AST nodes.
resolver: &'a mut dyn ResolverAstLowering
nt_to_tokenstream: NtToTokenstream
HACK(Centril): there is a cyclic dependency between the parser and lowering
if we don’t have this function pointer. To avoid that dependency so that
rustc_middle
is independent of the parser, we use dynamic dispatch here.
arena: &'hir Arena<'hir>
Used to allocate HIR nodes.
owners: IndexVec<LocalDefId, Option<OwnerInfo<'hir>>>
The items being lowered are collected here.
bodies: IndexVec<ItemLocalId, Option<&'hir Body<'hir>>>
Bodies inside the owner being lowered.
attrs: BTreeMap<ItemLocalId, &'hir [Attribute]>
Attributes inside the owner being lowered.
generator_kind: Option<GeneratorKind>
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 generator.
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<NodeId>
loop_scope: Option<NodeId>
is_in_loop_condition: bool
is_in_trait_impl: bool
is_in_dyn_type: bool
anonymous_lifetime_mode: AnonymousLifetimeMode
What to do when we encounter an “anonymous lifetime
reference”. The term “anonymous” is meant to encompass both
'_
lifetimes as well as fully elided cases where nothing is
written at all (e.g., &T
or std::cell::Ref<T>
).
lifetimes_to_define: Vec<(Span, ParamName)>
Used to create lifetime definitions from in-band lifetime usages.
e.g., fn foo(x: &'x u8) -> &'x u8
to fn foo<'x>(x: &'x u8) -> &'x u8
When a named lifetime is encountered in a function or impl header and
has not been defined
(i.e., it doesn’t appear in the in_scope_lifetimes list), it is added
to this list. The results of this list are then added to the list of
lifetime definitions in the corresponding impl or function generics.
is_collecting_in_band_lifetimes: bool
true
if in-band lifetimes are being collected. This is used to
indicate whether or not we’re in a place where new lifetimes will result
in in-band lifetime definitions, such a function or an impl header,
including implicit lifetimes from impl_header_lifetime_elision
.
in_scope_lifetimes: Vec<ParamName>
Currently in-scope lifetimes defined in impl headers, fn headers, or HRTB.
When is_collecting_in_band_lifetimes
is true, each lifetime is checked
against this list to see if it is already in-scope, or if a definition
needs to be created for it.
We always store a normalize_to_macros_2_0()
version of the param-name in this
vector.
current_hir_id_owner: LocalDefId
item_local_id_counter: ItemLocalId
node_id_to_hir_id: IndexVec<NodeId, Option<HirId>>
local_node_ids: Vec<NodeId>
NodeIds that are lowered inside the current HIR owner.
allow_try_trait: Option<Lrc<[Symbol]>>
allow_gen_future: Option<Lrc<[Symbol]>>
Implementations
fn lower_legacy_const_generics(
&mut self,
f: Expr,
args: Vec<AstP<Expr>>,
legacy_args_idx: &[usize]
) -> ExprKind<'hir>
fn lower_expr_while_in_loop_scope(
&mut self,
span: Span,
cond: &Expr,
body: &Block,
opt_label: Option<Label>
) -> 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.
fn wrap_in_try_constructor(
&mut self,
lang_item: LangItem,
method_span: Span,
expr: &'hir Expr<'hir>,
overall_span: Span
) -> &'hir Expr<'hir>
Lower an async
construct to a generator that is then wrapped so it implements Future
.
This results in:
std::future::from_generator(static move? |_task_context| -> <ret_ty> {
<body>
})
Desugar <expr>.await
into:
match <expr> {
mut pinned => loop {
match unsafe { ::std::future::Future::poll(
<::std::pin::Pin>::new_unchecked(&mut pinned),
::std::future::get_context(task_context),
) } {
::std::task::Poll::Ready(result) => break result,
::std::task::Poll::Pending => {}
}
task_context = yield ();
}
}
fn lower_expr_closure(
&mut self,
capture_clause: CaptureBy,
movability: Movability,
decl: &FnDecl,
body: &Expr,
fn_decl_span: Span
) -> ExprKind<'hir>
fn generator_movability_for_fn(
&mut self,
decl: &FnDecl,
fn_decl_span: Span,
generator_kind: Option<GeneratorKind>,
movability: Movability
) -> Option<Movability>
fn lower_expr_async_closure(
&mut self,
capture_clause: CaptureBy,
closure_id: NodeId,
decl: &FnDecl,
body: &Expr,
fn_decl_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; }
.
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.
Convert the LHS of a destructuring assignment to a pattern.
Each sub-assignment is recorded in assignments
.
fn destructure_assign_mut(
&mut self,
lhs: &Expr,
eq_sign_span: Span,
assignments: &mut Vec<Stmt<'hir>>
) -> Pat<'hir>
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
.
Desugar <start>..=<end>
into std::ops::RangeInclusive::new(<start>, <end>)
.
fn lower_expr_range(
&mut self,
span: Span,
e1: Option<&Expr>,
e2: Option<&Expr>,
lims: RangeLimits
) -> ExprKind<'hir>
Desugar ExprForLoop
from: [opt_ident]: for <pat> in <head> <body>
into:
{
let result = match ::std::iter::IntoIterator::into_iter(<head>) {
mut iter => {
[opt_ident]: loop {
let mut __next;
match ::std::iter::Iterator::next(&mut iter) {
::std::option::Option::Some(val) => __next = val,
::std::option::Option::None => break
};
let <pat> = __next;
StmtKind::Expr(<body>);
}
}
};
result
}
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),
}
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 { .. }
.
pub(crate) fn expr_drop_temps_mut(
&mut self,
span: Span,
expr: &'hir Expr<'hir>,
attrs: AttrVec
) -> Expr<'hir>
fn expr_match(
&mut self,
span: Span,
arg: &'hir Expr<'hir>,
arms: &'hir [Arm<'hir>],
source: MatchSource
) -> Expr<'hir>
fn expr_call_mut(
&mut self,
span: Span,
e: &'hir Expr<'hir>,
args: &'hir [Expr<'hir>]
) -> Expr<'hir>
fn expr_call(
&mut self,
span: Span,
e: &'hir Expr<'hir>,
args: &'hir [Expr<'hir>]
) -> &'hir Expr<'hir>
fn expr_call_lang_item_fn_mut(
&mut self,
span: Span,
lang_item: LangItem,
args: &'hir [Expr<'hir>]
) -> Expr<'hir>
fn expr_call_lang_item_fn(
&mut self,
span: Span,
lang_item: LangItem,
args: &'hir [Expr<'hir>]
) -> &'hir Expr<'hir>
fn expr_lang_item_path(
&mut self,
span: Span,
lang_item: LangItem,
attrs: AttrVec
) -> Expr<'hir>
pub(crate) fn expr_ident(
&mut self,
sp: Span,
ident: Ident,
binding: HirId
) -> &'hir Expr<'hir>
fn with_parent_item_lifetime_defs<T>(
&mut self,
parent_hir_id: LocalDefId,
f: impl FnOnce(&mut Self) -> T
) -> T
fn lower_item_id_use_tree(
&mut self,
tree: &UseTree,
base_id: NodeId,
vec: &mut SmallVec<[ItemId; 1]>
)
fn lower_item_kind(
&mut self,
span: Span,
id: NodeId,
hir_id: HirId,
ident: &mut Ident,
attrs: Option<&'hir [Attribute]>,
vis: &mut Visibility<'hir>,
i: &ItemKind
) -> ItemKind<'hir>
fn lower_const_item(
&mut self,
ty: &Ty,
span: Span,
body: Option<&Expr>
) -> (&'hir Ty<'hir>, BodyId)
fn lower_use_tree(
&mut self,
tree: &UseTree,
prefix: &Path,
id: NodeId,
vis: &mut Visibility<'hir>,
ident: &mut Ident,
attrs: Option<&'hir [Attribute]>
) -> ItemKind<'hir>
Paths like the visibility path in pub(super) use foo::{bar, baz}
are repeated
many times in the HIR tree; for each occurrence, we need to assign distinct
NodeId
s. (See, e.g., #56128.)
Construct ExprKind::Err
for the given span
.
If an explicit_owner
is given, this method allocates the HirId
in
the address space of that item instead of the item currently being
lowered. This can happen during lower_impl_item_ref()
where we need to
lower a Visibility
value although we haven’t lowered the owning
ImplItem
in question yet.
pub(crate) fn lower_body(
&mut self,
f: impl FnOnce(&mut Self) -> (&'hir [Param<'hir>], Expr<'hir>)
) -> BodyId
pub(crate) fn lower_fn_body(
&mut self,
decl: &FnDecl,
body: impl FnOnce(&mut Self) -> Expr<'hir>
) -> BodyId
fn lower_maybe_async_body(
&mut self,
span: Span,
decl: &FnDecl,
asyncness: Async,
body: Option<&Block>
) -> BodyId
fn lower_method_sig(
&mut self,
generics: &Generics,
sig: &FnSig,
fn_def_id: LocalDefId,
impl_trait_return_allow: bool,
is_async: Option<NodeId>
) -> (Generics<'hir>, FnSig<'hir>)
pub(crate) fn lower_generics_mut(
&mut self,
generics: &Generics,
itctx: ImplTraitContext<'_, 'hir>
) -> GenericsCtor<'hir>
pub(crate) fn lower_generics(
&mut self,
generics: &Generics,
itctx: ImplTraitContext<'_, 'hir>
) -> Generics<'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
.
fn lower_pat_ident(
&mut self,
p: &Pat,
binding_mode: &BindingMode,
ident: Ident,
lower_sub: impl FnOnce(&mut Self) -> Option<&'hir Pat<'hir>>
) -> PatKind<'hir>
Construct a Pat
with the HirId
of p.id
lowered.
Emit a friendly error for extra ..
patterns in a tuple/tuple struct/slice pattern.
Used to ban the ..
pattern in places it shouldn’t be semantically.
pub(crate) fn lower_qpath(
&mut self,
id: NodeId,
qself: &Option<QSelf>,
p: &Path,
param_mode: ParamMode,
itctx: ImplTraitContext<'_, 'hir>
) -> QPath<'hir>
pub(crate) fn lower_path_extra(
&mut self,
res: Res,
p: &Path,
param_mode: ParamMode
) -> &'hir Path<'hir>
pub(crate) fn lower_path(
&mut self,
id: NodeId,
p: &Path,
param_mode: ParamMode
) -> &'hir Path<'hir>
pub(crate) fn lower_path_segment(
&mut self,
path_span: Span,
segment: &PathSegment,
param_mode: ParamMode,
expected_lifetimes: usize,
parenthesized_generic_args: ParenthesizedGenericArgs,
itctx: ImplTraitContext<'_, 'hir>
) -> PathSegment<'hir>
pub(crate) fn lower_angle_bracketed_parameter_data(
&mut self,
data: &AngleBracketedArgs,
param_mode: ParamMode,
itctx: ImplTraitContext<'_, 'hir>
) -> (GenericArgsCtor<'hir>, bool)
fn lower_parenthesized_parameter_data(
&mut self,
data: &ParenthesizedArgs
) -> (GenericArgsCtor<'hir>, bool)
pub(crate) fn output_ty_binding(
&mut self,
span: Span,
ty: &'hir Ty<'hir>
) -> TypeBinding<'hir>
pub(crate) fn output_ty_binding(
&mut self,
span: Span,
ty: &'hir Ty<'hir>
) -> TypeBinding<'hir>
An associated type binding Output = $ty
.
Compute the hash for the HIR of the full crate. This hash will then be part of the crate_hash which is stored in the metadata.
pub(crate) fn with_hir_id_owner(
&mut self,
owner: NodeId,
f: impl FnOnce(&mut Self) -> OwnerNode<'hir>
) -> LocalDefId
pub(crate) fn hash_owner(
&mut self,
node: OwnerNode<'hir>,
bodies: &IndexVec<ItemLocalId, Option<&'hir Body<'hir>>>
) -> (Fingerprint, Fingerprint)
pub(crate) fn hash_owner(
&mut self,
node: OwnerNode<'hir>,
bodies: &IndexVec<ItemLocalId, Option<&'hir Body<'hir>>>
) -> (Fingerprint, Fingerprint)
Hash the HIR node twice, one deep and one shallow hash. This allows to differentiate queries which depend on the full HIR tree and those which only depend on the item signature.
This method allocates a new HirId
for the given NodeId
and stores it in
the LoweringContext
’s NodeId => HirId
map.
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 NodeId
s got mapped
properly. Calling the method twice with the same NodeId
is fine though.
pub(crate) fn expect_full_res_from_use(
&mut self,
id: NodeId
) -> impl Iterator<Item = Res<NodeId>>
pub(crate) fn mark_span_with_reason(
&self,
reason: DesugaringKind,
span: Span,
allow_internal_unstable: Option<Lrc<[Symbol]>>
) -> Span
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.
pub(crate) fn with_anonymous_lifetime_mode<R>(
&mut self,
anonymous_lifetime_mode: AnonymousLifetimeMode,
op: impl FnOnce(&mut Self) -> R
) -> R
Intercept all spans entering HIR. Mark a span as relative to the current owning item.
pub(crate) fn collect_in_band_defs<T>(
&mut self,
parent_def_id: LocalDefId,
anonymous_lifetime_mode: AnonymousLifetimeMode,
f: impl FnOnce(&mut Self) -> (Vec<GenericParam<'hir>>, T)
) -> (Vec<GenericParam<'hir>>, T)
pub(crate) fn collect_in_band_defs<T>(
&mut self,
parent_def_id: LocalDefId,
anonymous_lifetime_mode: AnonymousLifetimeMode,
f: impl FnOnce(&mut Self) -> (Vec<GenericParam<'hir>>, T)
) -> (Vec<GenericParam<'hir>>, T)
Creates a new hir::GenericParam
for every new lifetime and
type parameter encountered while evaluating f
. Definitions
are created with the parent provided. If no parent_id
is
provided, no definitions will be returned.
Presuming that in-band lifetimes are enabled, then
self.anonymous_lifetime_mode
will be updated to match the
parameter while f
is running (and restored afterwards).
pub(crate) fn lifetime_to_generic_param(
&mut self,
span: Span,
hir_name: ParamName,
parent_def_id: LocalDefId
) -> GenericParam<'hir>
pub(crate) fn lifetime_to_generic_param(
&mut self,
span: Span,
hir_name: ParamName,
parent_def_id: LocalDefId
) -> GenericParam<'hir>
Converts a lifetime into a new generic parameter.
When there is a reference to some lifetime 'a
, and in-band
lifetimes are enabled, then we want to push that lifetime into
the vector of names to define later. In that case, it will get
added to the appropriate generics.
When we have either an elided or '_
lifetime in an impl
header, we convert it to an in-band lifetime.
pub(crate) fn with_in_scope_lifetime_defs<T>(
&mut self,
params: &[GenericParam],
f: impl FnOnce(&mut Self) -> T
) -> T
pub(crate) fn add_in_band_defs<T>(
&mut self,
generics: &Generics,
parent_def_id: LocalDefId,
anonymous_lifetime_mode: AnonymousLifetimeMode,
f: impl FnOnce(&mut Self, &mut Vec<GenericParam<'hir>>) -> T
) -> (Generics<'hir>, T)
pub(crate) fn add_in_band_defs<T>(
&mut self,
generics: &Generics,
parent_def_id: LocalDefId,
anonymous_lifetime_mode: AnonymousLifetimeMode,
f: impl FnOnce(&mut Self, &mut Vec<GenericParam<'hir>>) -> T
) -> (Generics<'hir>, T)
Appends in-band lifetime defs and argument-position impl Trait
defs to the existing set of generics.
Presuming that in-band lifetimes are enabled, then
self.anonymous_lifetime_mode
will be updated to match the
parameter while f
is running (and restored afterwards).
pub(crate) fn with_dyn_type_scope<T>(
&mut self,
in_scope: bool,
f: impl FnOnce(&mut Self) -> T
) -> T
pub(crate) fn lower_token_stream(
&self,
tokens: TokenStream,
synthesize_tokens: CanSynthesizeMissingTokens
) -> TokenStream
pub(crate) fn lower_assoc_ty_constraint(
&mut self,
constraint: &AssocTyConstraint,
itctx: ImplTraitContext<'_, 'hir>
) -> TypeBinding<'hir>
pub(crate) fn lower_assoc_ty_constraint(
&mut self,
constraint: &AssocTyConstraint,
itctx: ImplTraitContext<'_, 'hir>
) -> TypeBinding<'hir>
Given an associated type constraint like one of these:
T: Iterator<Item: Debug>
^^^^^^^^^^^
T: Iterator<Item = Debug>
^^^^^^^^^^^^
returns a hir::TypeBinding
representing Item
.
pub(crate) fn lower_generic_arg(
&mut self,
arg: &GenericArg,
itctx: ImplTraitContext<'_, 'hir>
) -> GenericArg<'hir>
pub(crate) fn lower_ty(
&mut self,
t: &Ty,
itctx: ImplTraitContext<'_, 'hir>
) -> &'hir Ty<'hir>
pub(crate) fn lower_path_ty(
&mut self,
t: &Ty,
qself: &Option<QSelf>,
path: &Path,
param_mode: ParamMode,
itctx: ImplTraitContext<'_, 'hir>
) -> Ty<'hir>
pub(crate) fn lower_ty_direct(
&mut self,
t: &Ty,
itctx: ImplTraitContext<'_, 'hir>
) -> Ty<'hir>
pub(crate) fn lower_opaque_impl_trait(
&mut self,
span: Span,
fn_def_id: Option<DefId>,
origin: OpaqueTyOrigin,
opaque_ty_node_id: NodeId,
capturable_lifetimes: Option<&FxHashSet<LifetimeName>>,
lower_bounds: impl FnOnce(&mut Self) -> GenericBounds<'hir>
) -> TyKind<'hir>
pub(crate) fn generate_opaque_type(
&mut self,
opaque_ty_id: LocalDefId,
opaque_ty_item: OpaqueTy<'hir>,
span: Span,
opaque_ty_span: Span
) -> OwnerNode<'hir>
pub(crate) fn generate_opaque_type(
&mut self,
opaque_ty_id: LocalDefId,
opaque_ty_item: OpaqueTy<'hir>,
span: Span,
opaque_ty_span: Span
) -> OwnerNode<'hir>
Registers a new opaque type with the proper NodeId
s and
returns the lowered node-ID for the opaque type.
pub(crate) fn lower_fn_decl(
&mut self,
decl: &FnDecl,
in_band_ty_params: Option<(DefId, &mut Vec<GenericParam<'hir>>)>,
impl_trait_return_allow: bool,
make_ret_async: Option<NodeId>
) -> &'hir FnDecl<'hir>
pub(crate) fn lower_async_fn_ret_ty(
&mut self,
output: &FnRetTy,
fn_def_id: DefId,
opaque_ty_node_id: NodeId
) -> FnRetTy<'hir>
pub(crate) fn lower_async_fn_output_type_to_future_bound(
&mut self,
output: &FnRetTy,
fn_def_id: DefId,
span: Span
) -> GenericBound<'hir>
pub(crate) fn lower_async_fn_output_type_to_future_bound(
&mut self,
output: &FnRetTy,
fn_def_id: DefId,
span: Span
) -> GenericBound<'hir>
Transforms -> T
into Future<Output = T>
.
pub(crate) fn lower_param_bound(
&mut self,
tpb: &GenericBound,
itctx: ImplTraitContext<'_, 'hir>
) -> GenericBound<'hir>
pub(crate) fn new_named_lifetime(
&mut self,
id: NodeId,
span: Span,
name: LifetimeName
) -> Lifetime
pub(crate) fn lower_generic_params_mut<'s>(
&'s mut self,
params: &'s [GenericParam],
itctx: ImplTraitContext<'s, 'hir>
) -> impl Iterator<Item = GenericParam<'hir>> + Captures<'a> + Captures<'s>
pub(crate) fn lower_generic_params(
&mut self,
params: &[GenericParam],
itctx: ImplTraitContext<'_, 'hir>
) -> &'hir [GenericParam<'hir>]
pub(crate) fn lower_generic_param(
&mut self,
param: &GenericParam,
itctx: ImplTraitContext<'_, 'hir>
) -> GenericParam<'hir>
pub(crate) fn lower_trait_ref(
&mut self,
p: &TraitRef,
itctx: ImplTraitContext<'_, 'hir>
) -> TraitRef<'hir>
pub(crate) fn lower_poly_trait_ref(
&mut self,
p: &PolyTraitRef,
itctx: ImplTraitContext<'_, 'hir>
) -> PolyTraitRef<'hir>
pub(crate) fn lower_mt(
&mut self,
mt: &MutTy,
itctx: ImplTraitContext<'_, 'hir>
) -> MutTy<'hir>
pub(crate) fn lower_param_bounds(
&mut self,
bounds: &[GenericBound],
itctx: ImplTraitContext<'_, 'hir>
) -> GenericBounds<'hir>
pub(crate) fn lower_param_bounds_mut<'s>(
&'s mut self,
bounds: &'s [GenericBound],
itctx: ImplTraitContext<'s, 'hir>
) -> impl Iterator<Item = GenericBound<'hir>> + Captures<'s> + Captures<'a>
Lowers a block directly to an expression, presuming that it
has no attributes and is not targeted by a break
.
pub(crate) fn lower_trait_bound_modifier(
&mut self,
f: TraitBoundModifier
) -> TraitBoundModifier
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>
pub(crate) fn block_all(
&mut self,
span: Span,
stmts: &'hir [Stmt<'hir>],
expr: Option<&'hir Expr<'hir>>
) -> &'hir Block<'hir>
pub(crate) fn single_pat_field(
&mut self,
span: Span,
pat: &'hir Pat<'hir>
) -> &'hir [PatField<'hir>]
pub(crate) fn pat_lang_item_variant(
&mut self,
span: Span,
lang_item: LangItem,
fields: &'hir [PatField<'hir>]
) -> &'hir Pat<'hir>
pub(crate) fn pat_ident_binding_mode(
&mut self,
span: Span,
ident: Ident,
bm: BindingAnnotation
) -> (&'hir Pat<'hir>, HirId)
pub(crate) fn pat_ident_binding_mode_mut(
&mut self,
span: Span,
ident: Ident,
bm: BindingAnnotation
) -> (Pat<'hir>, HirId)
Invoked to create the lifetime argument for a type &T
with no explicit lifetime.
Report an error on illegal use of '_
or a &T
with no explicit lifetime;
return an “error lifetime”.
Invoked to create the lifetime argument(s) for a path like
std::cell::Ref<T>
; note that implicit lifetimes in these
sorts of cases are deprecated. This may therefore report a warning or an
error, depending on the mode.
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> !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
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: 288 bytes