[][src]Module syntax::ast

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

The Rust abstract syntax tree module.

This module contains common structures forming the language AST. Two main entities in the module are Item (which represents an AST element with additional metadata), and ItemKind (which represents a concrete type and contains information specific to the type of the item).

Other module items that worth mentioning:

Re-exports

pub use crate::util::parser::ExprPrecedence;
pub use GenericArgs::*;
pub use UnsafeSource::*;

Structs

AngleBracketedArgsInternal

A path like Foo<'a, T>.

AnonConstInternal

A constant (expression) that's not an item or associated item, but needs its own DefId for type-checking, const-eval, etc. These are usually found nested inside types (e.g., array lengths) or expressions (e.g., repeat counts), and also used to define explicit discriminant values for enum variants.

ArmInternal

An arm of a 'match'.

AssocItemInternal

Represents associated items. These include items in impl and trait definitions.

AssocTyConstraintInternal

A constraint on an associated type (e.g., A = Bar in Foo<A = Bar> or A: TraitA + TraitB in Foo<A: TraitA + TraitB>).

AttrIdInternal
AttrItemInternal
AttributeInternal

Metadata associated with an item.

BareFnTyInternal
BlockInternal

A block ({ .. }).

CrateInternal
EnumDefInternal
ExprInternal

An expression.

FieldInternal

Access of a named (e.g., obj.foo) or unnamed (e.g., obj.0) struct field.

FieldPatInternal

A single field in a struct pattern

FnDeclInternal

A signature (not the body) of a function declaration.

FnHeaderInternal

A function header.

FnSigInternal

Represents a function's signature in a trait declaration, trait implementation, or free function.

ForeignModInternal

Foreign module declaration.

GenericParamInternal
GenericsInternal

Represents lifetime, type and const parameters attached to a declaration of a function, enum, trait, etc.

GlobalAsmInternal

Global inline assembly.

IdentInternal
InlineAsmInternal

Inline assembly.

InlineAsmOutputInternal

Inline assembly.

ItemInternal

An item.

LabelInternal

A "Label" is an identifier of some point in sources, e.g. in the following code:

LifetimeInternal

A "Lifetime" is an annotation of the scope in which variable can be used, e.g. 'a in &'a i32.

LitInternal

An AST literal.

LocalInternal

Local represents a let statement, e.g., let <pat>:<ty> = <expr>;.

MacInternal

Represents a macro invocation. The path indicates which macro is being invoked, and the args are arguments passed to it.

MacroDefInternal

Represents a macro definition.

MetaItemInternal

A spanned compile-time attribute item.

ModInternal

Module declaration.

MutTyInternal
NameInternal

An interned string.

NodeIdInternal
ParamInternal

A parameter in a function header.

ParenthesizedArgsInternal

A path like Foo(A, B) -> C.

PatInternal
PathInternal

A "Path" is essentially Rust's notion of a name.

PathSegmentInternal

A segment of a path: an identifier, an optional lifetime, and a set of types.

PolyTraitRefInternal
QSelfInternal

The explicit Self type in a "qualified path". The actual path, including the trait and the associated item, is stored separately. position represents the index of the associated item qualified with this Self type.

StmtInternal

A statement

StrLitInternal

Same as Lit, but restricted to string literals.

StructFieldInternal

Field of a struct.

TraitRefInternal

TraitRefs appear in impls.

TyInternal
UseTreeInternal

A tree of paths sharing common prefixes. Used in use items both at top-level and inside of braces in import groups.

VariantInternal

Enum variant.

WhereBoundPredicateInternal

A type bound.

WhereClauseInternal

A where-clause in a definition.

WhereEqPredicateInternal

An equality predicate (unsupported).

WhereRegionPredicateInternal

A lifetime predicate.

Enums

AsmDialectInternal

Inline assembly dialect.

AssocItemKindInternal

Represents various kinds of content within an impl.

AssocTyConstraintKindInternal

The kinds of an AssocTyConstraint.

AttrKindInternal
AttrStyleInternal

Distinguishes between Attributes that decorate items and Attributes that are contained as statements within items. These two cases need to be distinguished for pretty-printing.

BinOpKindInternal
BindingModeInternal
BlockCheckModeInternal
BorrowKindInternal

The kind of borrow in an AddrOf expression, e.g., &place or &raw const place.

CaptureByInternal

A capture clause used in closures and async blocks.

ConstnessInternal
CrateSugarInternal
DefaultnessInternal

Item defaultness. For details see the RFC #2532.

ExprKindInternal
ExternInternal

extern qualifier on a function item or function type.

FloatTyInternal
ForeignItemKindInternal

An item within an extern block.

FunctionRetTyInternal
GenericArgInternal

Concrete argument in the sequence of generic args.

GenericArgsInternal

The arguments of a path segment.

GenericBoundInternal

The AST represents all type param bounds as types. typeck::collect::compute_bounds matches these against the "special" built-in traits (see middle::lang_items) and detects Copy, Send and Sync.

GenericParamKindInternal
ImplPolarityInternal
IntTyInternal
IsAsyncInternal
IsAutoInternal

Is the trait definition an auto trait?

ItemKindInternal
LitFloatTypeInternal

Type of the float literal based on provided suffix.

LitIntTypeInternal

Type of the integer literal based on provided suffix.

LitKindInternal

Literal kind.

MacArgsInternal

Arguments passed to an attribute or a function-like macro.

MacDelimiterInternal
MacStmtStyleInternal
MetaItemKindInternal

A compile-time attribute item.

MovabilityInternal

The movability of a generator / closure literal: whether a generator contains self-references, causing it to be !Unpin.

MutabilityInternal
NestedMetaItemInternal

Possible values inside of compile-time attribute lists.

ParamKindOrdInternal

Specifies the enforced ordering for generic parameters. In the future, if we wanted to relax this order, we could override PartialEq and PartialOrd, to allow the kinds to be unordered.

PatKindInternal
RangeEndInternal
RangeLimitsInternal

Limit types of a range (inclusive or exclusive)

RangeSyntaxInternal
SelfKindInternal

Alternative representation for Args describing self parameter of methods.

StmtKindInternal
StrStyleInternal
TraitBoundModifierInternal

A modifier on a bound, e.g., ?Sized or ?const Trait.

TraitObjectSyntaxInternal

Syntax used to declare a trait object.

TyKindInternal

The various kinds of type recognized by the compiler.

UintTyInternal
UnOpInternal

Unary operator.

UnsafeSourceInternal
UnsafetyInternal
UseTreeKindInternal

Part of use item to the right of its prefix.

VariantDataInternal

Fields and constructor ids of enum variants and structs.

VisibilityKindInternal
WherePredicateInternal

A single predicate in a where-clause.

Constants

CRATE_NODE_IDInternal

NodeId used to represent the root of the crate.

DUMMY_NODE_IDInternal

When parsing and doing expansions, we initially give all AST nodes this AST node value. Then later, in the renumber pass, we renumber them to have small, positive ids.

Type Definitions

AttrVecInternal

A list of attributes.

BinOpInternal
CrateConfigInternal

The set of keys (and, optionally, values) that define the compilation environment of the crate, used to drive conditional compilation.

ExplicitSelfInternal
ForeignItemInternal
GenericBoundsInternal
VisibilityInternal