[][src]Module rustc_ap_rustc_ast::ast

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 worth mentioning:

Re-exports

pub use crate::util::parser::ExprPrecedence;
pub use GenericArgs::*;
pub use UnsafeSource::*;
pub use crate::node_id::NodeId;
pub use crate::node_id::CRATE_NODE_ID;
pub use crate::node_id::DUMMY_NODE_ID;

Structs

AngleBracketedArgs

A path like Foo<'a, T>.

AnonConst

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.

Arm

An arm of a 'match'.

AssocTyConstraint

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

AttrId
AttrItem
Attribute

Metadata associated with an item.

BareFnTy
Block

A block ({ .. }).

Crate
EnumDef
Expr

An expression.

Field

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

FieldPat

A single field in a struct pattern.

FnDecl

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

FnHeader

A function header.

FnSig

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

ForeignMod

Foreign module declaration.

GenericParam
Generics

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

GlobalAsm

Global inline assembly.

InlineAsm

Inline assembly.

InlineAsmOptions
Item

An item definition.

Label

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

Lifetime

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

Lit

An AST literal.

LlvmInlineAsm

LLVM-style inline assembly.

LlvmInlineAsmOutput

LLVM-style inline assembly.

Local

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

MacCall

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

MacCallStmt
MacroDef

Represents a macro definition.

MetaItem

A spanned compile-time attribute item.

Mod

Module declaration.

MutTy
Param

A parameter in a function header.

ParenthesizedArgs

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

Pat

A match pattern.

Path

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

PathSegment

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

PolyTraitRef
QSelf

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.

Stmt

A statement

StrLit

Same as Lit, but restricted to string literals.

StructField

Field of a struct.

TraitRef

TraitRefs appear in impls.

Ty
UseTree

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

Variant

Enum variant.

Visibility
WhereBoundPredicate

A type bound.

WhereClause

A where-clause in a definition.

WhereEqPredicate

An equality predicate (unsupported).

WhereRegionPredicate

A lifetime predicate.

Enums

AngleBracketedArg

Either an argument for a parameter e.g., 'a, Vec<u8>, 0, or a constraint on an associated item, e.g., Item = String or Item: Bound.

AssocItemKind

Represents associated item kinds.

AssocTyConstraintKind

The kinds of an AssocTyConstraint.

Async
AttrKind
AttrStyle

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.

BinOpKind
BindingMode
BlockCheckMode
BorrowKind

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

CaptureBy

A capture clause used in closures and async blocks.

Const
CrateSugar
Defaultness

Item defaultness. For details see the RFC #2532.

ExprKind
Extern

extern qualifier on a function item or function type.

FloatTy
FnRetTy
ForeignItemKind

An item in extern block.

GenericArg

Concrete argument in the sequence of generic args.

GenericArgs

The arguments of a path segment.

GenericBound

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.

GenericParamKind
ImplPolarity
InlineAsmOperand

Inline assembly operand.

InlineAsmRegOrRegClass

Inline assembly operand explicit register or register class.

InlineAsmTemplatePiece
IntTy
IsAuto

Is the trait definition an auto trait?

ItemKind
LitFloatType

Type of the float literal based on provided suffix.

LitIntType

Type of the integer literal based on provided suffix.

LitKind

Literal kind.

LlvmAsmDialect

Inline assembly dialect.

MacArgs

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

MacDelimiter
MacStmtStyle
MetaItemKind

A compile-time attribute item.

Movability

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

Mutability
NestedMetaItem

Possible values inside of compile-time attribute lists.

ParamKindOrd

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.

PatKind
RangeEnd
RangeLimits

Limit types of a range (inclusive or exclusive)

RangeSyntax
SelfKind

Alternative representation for Args describing self parameter of methods.

StmtKind
StrStyle
StructRest
TraitBoundModifier

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

TraitObjectSyntax

Syntax used to declare a trait object.

TyKind

The various kinds of type recognized by the compiler.

UintTy
UnOp

Unary operator.

Unsafe
UnsafeSource
UseTreeKind

Part of use item to the right of its prefix.

VariantData

Fields and constructor ids of enum variants and structs.

VisibilityKind
WherePredicate

A single predicate in a where-clause.

Type Definitions

AssocItem

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

AttrVec

A list of attributes.

BinOp
ExplicitSelf
ForeignItem
GenericBounds