pub enum Node<'hir> {
Show 32 variants
Param(&'hir Param<'hir>),
Item(&'hir Item<'hir>),
ForeignItem(&'hir ForeignItem<'hir>),
TraitItem(&'hir TraitItem<'hir>),
ImplItem(&'hir ImplItem<'hir>),
Variant(&'hir Variant<'hir>),
Field(&'hir FieldDef<'hir>),
AnonConst(&'hir AnonConst),
ConstBlock(&'hir ConstBlock),
ConstArg(&'hir ConstArg<'hir>),
Expr(&'hir Expr<'hir>),
ExprField(&'hir ExprField<'hir>),
Stmt(&'hir Stmt<'hir>),
PathSegment(&'hir PathSegment<'hir>),
Ty(&'hir Ty<'hir>),
AssocItemConstraint(&'hir AssocItemConstraint<'hir>),
TraitRef(&'hir TraitRef<'hir>),
Pat(&'hir Pat<'hir>),
PatField(&'hir PatField<'hir>),
Arm(&'hir Arm<'hir>),
Block(&'hir Block<'hir>),
LetStmt(&'hir LetStmt<'hir>),
Ctor(&'hir VariantData<'hir>),
Lifetime(&'hir Lifetime),
GenericParam(&'hir GenericParam<'hir>),
Crate(&'hir Mod<'hir>),
Infer(&'hir InferArg),
WhereBoundPredicate(&'hir WhereBoundPredicate<'hir>),
ArrayLenInfer(&'hir InferArg),
PreciseCapturingNonLifetimeArg(&'hir PreciseCapturingNonLifetimeArg),
Synthetic,
Err(Span),
}
Variants§
Param(&'hir Param<'hir>)
Item(&'hir Item<'hir>)
ForeignItem(&'hir ForeignItem<'hir>)
TraitItem(&'hir TraitItem<'hir>)
ImplItem(&'hir ImplItem<'hir>)
Variant(&'hir Variant<'hir>)
Field(&'hir FieldDef<'hir>)
AnonConst(&'hir AnonConst)
ConstBlock(&'hir ConstBlock)
ConstArg(&'hir ConstArg<'hir>)
Expr(&'hir Expr<'hir>)
ExprField(&'hir ExprField<'hir>)
Stmt(&'hir Stmt<'hir>)
PathSegment(&'hir PathSegment<'hir>)
Ty(&'hir Ty<'hir>)
AssocItemConstraint(&'hir AssocItemConstraint<'hir>)
TraitRef(&'hir TraitRef<'hir>)
Pat(&'hir Pat<'hir>)
PatField(&'hir PatField<'hir>)
Arm(&'hir Arm<'hir>)
Block(&'hir Block<'hir>)
LetStmt(&'hir LetStmt<'hir>)
Ctor(&'hir VariantData<'hir>)
Ctor
refers to the constructor of an enum variant or struct. Only tuple or unit variants
with synthesized constructors.
Lifetime(&'hir Lifetime)
GenericParam(&'hir GenericParam<'hir>)
Crate(&'hir Mod<'hir>)
Infer(&'hir InferArg)
WhereBoundPredicate(&'hir WhereBoundPredicate<'hir>)
ArrayLenInfer(&'hir InferArg)
PreciseCapturingNonLifetimeArg(&'hir PreciseCapturingNonLifetimeArg)
Synthetic
Err(Span)
Implementations§
source§impl<'hir> Node<'hir>
impl<'hir> Node<'hir>
sourcepub fn ident(&self) -> Option<Ident>
pub fn ident(&self) -> Option<Ident>
Get the identifier of this Node
, if applicable.
§Edge cases
Calling .ident()
on a Node::Ctor
will return None
because Ctor
s do not have identifiers themselves.
Instead, call .ident()
on the parent struct/variant, like so:
ctor
.ctor_hir_id()
.map(|ctor_id| tcx.parent_hir_node(ctor_id))
.and_then(|parent| parent.ident())
pub fn fn_decl(self) -> Option<&'hir FnDecl<'hir>>
sourcepub fn impl_block_of_trait(
self,
trait_def_id: DefId,
) -> Option<&'hir Impl<'hir>>
pub fn impl_block_of_trait( self, trait_def_id: DefId, ) -> Option<&'hir Impl<'hir>>
Get a hir::Impl
if the node is an impl block for the given trait_def_id
.
pub fn fn_sig(self) -> Option<&'hir FnSig<'hir>>
sourcepub fn ty(self) -> Option<&'hir Ty<'hir>>
pub fn ty(self) -> Option<&'hir Ty<'hir>>
Get the type for constants, assoc types, type aliases and statics.
pub fn alias_ty(self) -> Option<&'hir Ty<'hir>>
pub fn associated_body(&self) -> Option<(LocalDefId, BodyId)>
pub fn body_id(&self) -> Option<BodyId>
pub fn generics(self) -> Option<&'hir Generics<'hir>>
pub fn as_owner(self) -> Option<OwnerNode<'hir>>
pub fn fn_kind(self) -> Option<FnKind<'hir>>
pub fn expect_param(&self) -> &'hir Param<'hir>
pub fn expect_item(&self) -> &'hir Item<'hir>
pub fn expect_foreign_item(&self) -> &'hir ForeignItem<'hir>
pub fn expect_trait_item(&self) -> &'hir TraitItem<'hir>
pub fn expect_impl_item(&self) -> &'hir ImplItem<'hir>
pub fn expect_variant(&self) -> &'hir Variant<'hir>
pub fn expect_field(&self) -> &'hir FieldDef<'hir>
pub fn expect_anon_const(&self) -> &'hir AnonConst
pub fn expect_inline_const(&self) -> &'hir ConstBlock
pub fn expect_expr(&self) -> &'hir Expr<'hir>
pub fn expect_expr_field(&self) -> &'hir ExprField<'hir>
pub fn expect_stmt(&self) -> &'hir Stmt<'hir>
pub fn expect_path_segment(&self) -> &'hir PathSegment<'hir>
pub fn expect_ty(&self) -> &'hir Ty<'hir>
pub fn expect_assoc_item_constraint(&self) -> &'hir AssocItemConstraint<'hir>
pub fn expect_trait_ref(&self) -> &'hir TraitRef<'hir>
pub fn expect_pat(&self) -> &'hir Pat<'hir>
pub fn expect_pat_field(&self) -> &'hir PatField<'hir>
pub fn expect_arm(&self) -> &'hir Arm<'hir>
pub fn expect_block(&self) -> &'hir Block<'hir>
pub fn expect_let_stmt(&self) -> &'hir LetStmt<'hir>
pub fn expect_ctor(&self) -> &'hir VariantData<'hir>
pub fn expect_lifetime(&self) -> &'hir Lifetime
pub fn expect_generic_param(&self) -> &'hir GenericParam<'hir>
pub fn expect_crate(&self) -> &'hir Mod<'hir>
pub fn expect_infer(&self) -> &'hir InferArg
pub fn expect_closure(&self) -> &'hir Closure<'hir>
Trait Implementations§
source§impl<'hir, __CTX> HashStable<__CTX> for Node<'hir>where
__CTX: HashStableContext,
impl<'hir, __CTX> HashStable<__CTX> for Node<'hir>where
__CTX: HashStableContext,
fn hash_stable(&self, __hcx: &mut __CTX, __hasher: &mut StableHasher)
impl<'hir> Copy for Node<'hir>
Auto Trait Implementations§
impl<'hir> Freeze for Node<'hir>
impl<'hir> !RefUnwindSafe for Node<'hir>
impl<'hir> !Send for Node<'hir>
impl<'hir> !Sync for Node<'hir>
impl<'hir> Unpin for Node<'hir>
impl<'hir> !UnwindSafe for Node<'hir>
Blanket Implementations§
source§impl<'tcx, T> ArenaAllocatable<'tcx, IsCopy> for Twhere
T: Copy,
impl<'tcx, T> ArenaAllocatable<'tcx, IsCopy> for Twhere
T: Copy,
fn allocate_on<'a>(self, arena: &'a Arena<'tcx>) -> &'a mut T
fn allocate_from_iter<'a>( arena: &'a Arena<'tcx>, iter: impl IntoIterator<Item = T>, ) -> &'a mut [T]
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moresource§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
impl<'a, T> Captures<'a> for Twhere
T: ?Sized,
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: 16 bytes
Size for each variant:
Param
: 12 bytesItem
: 12 bytesForeignItem
: 12 bytesTraitItem
: 12 bytesImplItem
: 12 bytesVariant
: 12 bytesField
: 12 bytesAnonConst
: 12 bytesConstBlock
: 12 bytesConstArg
: 12 bytesExpr
: 12 bytesExprField
: 12 bytesStmt
: 12 bytesPathSegment
: 12 bytesTy
: 12 bytesAssocItemConstraint
: 12 bytesTraitRef
: 12 bytesPat
: 12 bytesPatField
: 12 bytesArm
: 12 bytesBlock
: 12 bytesLetStmt
: 12 bytesCtor
: 12 bytesLifetime
: 12 bytesGenericParam
: 12 bytesCrate
: 12 bytesInfer
: 12 bytesWhereBoundPredicate
: 12 bytesArrayLenInfer
: 12 bytesPreciseCapturingNonLifetimeArg
: 12 bytesSynthetic
: 0 bytesErr
: 8 bytes