# Enum rustc_hir::hir::Node

source ·

    pub enum Node<'hir> {
    Show 30 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),
        Expr(&'hir Expr<'hir>),
        ExprField(&'hir ExprField<'hir>),
        Stmt(&'hir Stmt<'hir>),
        PathSegment(&'hir PathSegment<'hir>),
        Ty(&'hir Ty<'hir>),
        TypeBinding(&'hir TypeBinding<'hir>),
        TraitRef(&'hir TraitRef<'hir>),
        Pat(&'hir Pat<'hir>),
        PatField(&'hir PatField<'hir>),
        Arm(&'hir Arm<'hir>),
        Block(&'hir Block<'hir>),
        Local(&'hir Local<'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),
        Synthetic,
        Err(&'hir 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)

§

### Expr(&'hir Expr<'hir>)

§

### ExprField(&'hir ExprField<'hir>)

§

### Stmt(&'hir Stmt<'hir>)

§

### PathSegment(&'hir PathSegment<'hir>)

§

### Ty(&'hir Ty<'hir>)

§

### TypeBinding(&'hir TypeBinding<'hir>)

§

### TraitRef(&'hir TraitRef<'hir>)

§

### Pat(&'hir Pat<'hir>)

§

### PatField(&'hir PatField<'hir>)

§

### Arm(&'hir Arm<'hir>)

§

### Block(&'hir Block<'hir>)

§

### Local(&'hir Local<'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)

§

### Synthetic

§

### Err(&'hir Span)

## Implementations§

source§

### impl<'hir> Node<'hir>

source

#### 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())

source

#### pub fn fn_decl(self) -> Option<&'hir FnDecl<'hir>>

source

#### pub fn fn_sig(self) -> Option<&'hir FnSig<'hir>>

source

#### pub fn ty(self) -> Option<&'hir Ty<'hir>>

Get the type for constants, assoc types, type aliases and statics.

source

#### pub fn alias_ty(self) -> Option<&'hir Ty<'hir>>

source

#### pub fn associated_body(&self) -> Option<(LocalDefId, BodyId)>

source

#### pub fn body_id(&self) -> Option<BodyId>

source

#### pub fn generics(self) -> Option<&'hir Generics<'hir>>

source

#### pub fn as_owner(self) -> Option<OwnerNode<'hir>>

source

#### pub fn fn_kind(self) -> Option<FnKind<'hir>>

source

#### pub fn expect_param(&self) -> &'hir Param<'hir>

source

#### pub fn expect_item(&self) -> &'hir Item<'hir>

source

#### pub fn expect_foreign_item(&self) -> &'hir ForeignItem<'hir>

source

#### pub fn expect_trait_item(&self) -> &'hir TraitItem<'hir>

source

#### pub fn expect_impl_item(&self) -> &'hir ImplItem<'hir>

source

#### pub fn expect_variant(&self) -> &'hir Variant<'hir>

source

#### pub fn expect_field(&self) -> &'hir FieldDef<'hir>

source

#### pub fn expect_anon_const(&self) -> &'hir AnonConst

source

#### pub fn expect_inline_const(&self) -> &'hir ConstBlock

source

#### pub fn expect_expr(&self) -> &'hir Expr<'hir>

source

#### pub fn expect_expr_field(&self) -> &'hir ExprField<'hir>

source

#### pub fn expect_stmt(&self) -> &'hir Stmt<'hir>

source

#### pub fn expect_path_segment(&self) -> &'hir PathSegment<'hir>

source

#### pub fn expect_ty(&self) -> &'hir Ty<'hir>

source

#### pub fn expect_type_binding(&self) -> &'hir TypeBinding<'hir>

source

#### pub fn expect_trait_ref(&self) -> &'hir TraitRef<'hir>

source

#### pub fn expect_pat(&self) -> &'hir Pat<'hir>

source

#### pub fn expect_pat_field(&self) -> &'hir PatField<'hir>

source

#### pub fn expect_arm(&self) -> &'hir Arm<'hir>

source

#### pub fn expect_block(&self) -> &'hir Block<'hir>

source

#### pub fn expect_local(&self) -> &'hir Local<'hir>

source

#### pub fn expect_ctor(&self) -> &'hir VariantData<'hir>

source

#### pub fn expect_lifetime(&self) -> &'hir Lifetime

source

#### pub fn expect_generic_param(&self) -> &'hir GenericParam<'hir>

source

#### pub fn expect_crate(&self) -> &'hir Mod<'hir>

source

#### pub fn expect_infer(&self) -> &'hir InferArg

source

#### pub fn expect_closure(&self) -> &'hir Closure<'hir>

## Trait Implementations§

source§

### impl<'hir> Clone for Node<'hir>

source§

#### fn clone(&self) -> Node<'hir>

Returns a copy of the value. Read more
1.0.0 · source§

#### fn clone_from(&mut self, source: &Self)

Performs copy-assignment from `source`. Read more
source§

### impl<'hir> Debug for Node<'hir>

source§

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

Formats the value using the given formatter. Read more
source§

### impl<'hir, __CTX> HashStable<__CTX> for Node<'hir>
where __CTX: HashStableContext,

source§

#### fn hash_stable(&self, __hcx: &mut __CTX, __hasher: &mut StableHasher)

source§

### impl<'hir> Into<Node<'hir>> for OwnerNode<'hir>

source§

#### fn into(self) -> Node<'hir>

Converts this type into the (usually inferred) input type.
source§

### impl<'hir> Copy for Node<'hir>

## Auto Trait Implementations§

§

### impl<'hir> DynSend for Node<'hir>

§

### impl<'hir> DynSync for Node<'hir>

§

### 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<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<'tcx, T> ArenaAllocatable<'tcx, IsCopy> for T
where T: Copy,

source§

#### fn allocate_on<'a>(self, arena: &'a Arena<'tcx>) -> &'a mut T

source§

#### fn allocate_from_iter<'a>( arena: &'a Arena<'tcx>, iter: impl IntoIterator<Item = T> ) -> &'a mut [T]

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

§

### 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> Same for T

§

#### type Output = T

Should always be `Self`
source§

### impl<T> ToOwned for T
where T: Clone,

§

#### type Owned = T

The resulting type after obtaining ownership.
source§

#### fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

#### fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

#### 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>,

§

#### 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<V, T> VZip<V> for T
where V: MultiLane<T>,

§

#### fn vzip(self) -> V

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,

## 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`: 8 bytes
- `Item`: 8 bytes
- `ForeignItem`: 8 bytes
- `TraitItem`: 8 bytes
- `ImplItem`: 8 bytes
- `Variant`: 8 bytes
- `Field`: 8 bytes
- `AnonConst`: 8 bytes
- `ConstBlock`: 8 bytes
- `Expr`: 8 bytes
- `ExprField`: 8 bytes
- `Stmt`: 8 bytes
- `PathSegment`: 8 bytes
- `Ty`: 8 bytes
- `TypeBinding`: 8 bytes
- `TraitRef`: 8 bytes
- `Pat`: 8 bytes
- `PatField`: 8 bytes
- `Arm`: 8 bytes
- `Block`: 8 bytes
- `Local`: 8 bytes
- `Ctor`: 8 bytes
- `Lifetime`: 8 bytes
- `GenericParam`: 8 bytes
- `Crate`: 8 bytes
- `Infer`: 8 bytes
- `WhereBoundPredicate`: 8 bytes
- `ArrayLenInfer`: 8 bytes
- `Synthetic`: 0 bytes
- `Err`: 8 bytes