rustc_hir::hir

Enum Node

source
pub enum Node<'hir> {
Show 33 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>), OpaqueTy(&'hir OpaqueTy<'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>)

§

OpaqueTy(&'hir OpaqueTy<'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>

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

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_assoc_item_constraint(&self) -> &'hir AssocItemConstraint<'hir>

source

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

source

pub fn expect_opaque_ty(&self) -> &'hir OpaqueTy<'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_let_stmt(&self) -> &'hir LetStmt<'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> 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(self, arena: &'tcx Arena<'tcx>) -> &'tcx mut T

source§

fn allocate_from_iter( arena: &'tcx Arena<'tcx>, iter: impl IntoIterator<Item = T>, ) -> &'tcx 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> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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<T> Same for T

source§

type Output = T

Should always be Self
source§

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

source§

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

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

source§

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: 12 bytes
  • Item: 12 bytes
  • ForeignItem: 12 bytes
  • TraitItem: 12 bytes
  • ImplItem: 12 bytes
  • Variant: 12 bytes
  • Field: 12 bytes
  • AnonConst: 12 bytes
  • ConstBlock: 12 bytes
  • ConstArg: 12 bytes
  • Expr: 12 bytes
  • ExprField: 12 bytes
  • Stmt: 12 bytes
  • PathSegment: 12 bytes
  • Ty: 12 bytes
  • AssocItemConstraint: 12 bytes
  • TraitRef: 12 bytes
  • OpaqueTy: 12 bytes
  • Pat: 12 bytes
  • PatField: 12 bytes
  • Arm: 12 bytes
  • Block: 12 bytes
  • LetStmt: 12 bytes
  • Ctor: 12 bytes
  • Lifetime: 12 bytes
  • GenericParam: 12 bytes
  • Crate: 12 bytes
  • Infer: 12 bytes
  • WhereBoundPredicate: 12 bytes
  • ArrayLenInfer: 12 bytes
  • PreciseCapturingNonLifetimeArg: 12 bytes
  • Synthetic: 0 bytes
  • Err: 8 bytes