Expand description
Abstract Syntax Tree, layered on top of untyped SyntaxNodes
Modulesยง
- edit
- This module contains functions for editing syntax trees. As the trees are immutable, all function here return a fresh copy of the tree, instead of doing an in-place modification.
- expr_
ext ๐ - Various extension methods to ast Expr Nodes, which are hard to code-generate.
- generated ๐
- This file is actually hand-written, but the submodules are indeed generated.
- make
- This module contains free-standing functions for creating AST fragments out of smaller pieces.
- node_
ext ๐ - Various extension methods to ast Nodes, which are hard to code-generate.
Extensions for various expressions live in a sibling
expr_extensionsmodule. - operators ๐
- Defines a bunch of data-less enums for unary and binary operators.
- prec
- Precedence representation.
- support ๐
- syntax_
factory - Builds upon
crate::ast::makeconstructors to create ast fragments with optional syntax mappings. - token_
ext ๐ - There are many AstNodes, but only a few tokens, so we hand-write them here.
- traits ๐
- Various traits that are implemented by ast nodes.
Structsยง
- Abi
- AnyComment
- AnyHas
ArgList - AnyHas
Attrs - AnyHas
Generic Args - AnyHas
Generic Params - AnyHas
Loop Body - AnyHas
Module Item - AnyHas
Name - AnyHas
Type Bounds - AnyHas
Visibility - ArgList
- Array
Expr - Array
Type - AsmClobber
Abi - AsmConst
- AsmDir
Spec - AsmExpr
- AsmLabel
- AsmOperand
Expr - AsmOperand
Named - AsmOption
- AsmOptions
- AsmReg
Operand - AsmReg
Spec - AsmSym
- Assoc
Item List - Assoc
Type Arg - AstChildren
- An iterator over
SyntaxNodechildren of a particular AST type. - Attr
- Attrs
Iter - Await
Expr - Become
Expr - BinExpr
- Block
Expr - BoxPat
- Break
Expr - Byte
- Byte
String - CString
- Call
Expr - Cast
Expr - CfgAtom
- CfgAttr
Meta - CfgComposite
- CfgMeta
- CfgPred
Expr - CfgPred
Pat - Char
- Closure
Expr - Comment
- Comment
Kind - Const
- Const
Arg - Const
Block Pat - Const
Param - Continue
Expr - Deref
Pat - DocComment
- DynTrait
Type - Enum
- Expr
Stmt - Extern
Block - Extern
Crate - Extern
Item List - Field
Expr - Float
Number - Fn
- FnPtr
Type - ForBinder
- ForExpr
- ForType
- Format
Args Arg - Format
Args Expr - Generic
ArgList - Generic
Param List - Ident
- Ident
Pat - IfExpr
- Impl
- Impl
Restriction - Impl
Trait Type - Include
Bytes Expr - Index
Expr - Infer
Type - IntNumber
- Item
List - KeyValue
Meta - Label
- LetElse
- LetExpr
- LetStmt
- Lifetime
- Lifetime
Arg - Lifetime
Param - Literal
- Literal
Pat - Loop
Expr - Macro
Call - Macro
Def - Macro
Expr - Macro
Items - Macro
Pat - Macro
Rules - Macro
Stmts - Macro
Type - Match
Arm - Match
ArmList - Match
Expr - Match
Guard - Method
Call Expr - Module
- MutRestriction
- Name
- NameRef
- Never
Type - NotNull
- Offset
OfExpr - OrPat
- Param
- Param
List - Paren
Expr - Paren
Pat - Paren
Type - Parenthesized
ArgList - Path
- Path
Expr - Path
Meta - PathPat
- Path
Segment - Path
Type - Pattern
Type - Prefix
Expr - PtrType
- Quote
Offsets - Range
Expr - Range
Pat - Record
Expr - Record
Expr Field - Record
Expr Field List - Record
Field - Record
Field List - Record
Pat - Record
PatField - Record
PatField List - RefExpr
- RefPat
- RefType
- Rename
- RestPat
- RetType
- Return
Expr - Return
Type Syntax - Self
Param - Slice
Pat - Slice
PatComponents - Slice
Type - Source
File - Static
- Stmt
List - String
- Struct
- Token
Tree - Token
Tree Children - An iterator over the elements in an
ast::TokenTree. - Token
Tree Meta - Trait
- TryBlock
Modifier - TryExpr
- Tuple
Expr - Tuple
Field - Tuple
Field List - Tuple
Pat - Tuple
Struct Pat - Tuple
Type - Type
Alias - Type
Anchor - TypeArg
- Type
Bound - Type
Bound List - Type
Param - Underscore
Expr - Union
- Unsafe
Meta - Use
- UseBound
Generic Args - UseTree
- UseTree
List - Variant
- Variant
List - Visibility
- Visibility
Inner - Where
Clause - Where
Pred - While
Expr - Whitespace
- Wildcard
Pat - Yeet
Expr - Yield
Expr
Enumsยง
- Adt
- AnyAttr
- AnyString
- ArithOp
- Array
Expr Kind - AsmOperand
- AsmPiece
- Assoc
Item - Attr
Kind - Binary
Op - Block
Modifier - Callable
Expr - CfgAtom
Key - CfgPredicate
- CmpOp
- Comment
Shape - Else
Branch - Expr
- Extern
Item - Field
Kind - Field
List - Generic
Arg - Generic
Param - Item
- Literal
Kind - LogicOp
- Macro
- Meta
- Name
Like - Name
OrName Ref - Ordering
- Pat
- Path
Segment Kind - Radix
- RangeOp
- Self
Param Kind - Stmt
- Struct
Kind - Type
- Type
Bound Kind - Type
OrConst Param - UnaryOp
- UseBound
Generic Arg - Variant
Def - Visibility
Kind
Traitsยง
- AstNode
- The main trait to go from untyped
SyntaxNodeto a typed ast. The conversion itself has zero runtime cost: ast and syntax nodes have exactly the same representation: a pointer to the tree root and a pointer to the node itself. - AstToken
- Like
AstNode, but wraps tokens rather than interior nodes. - HasArg
List - HasAttrs
- HasGeneric
Args - HasGeneric
Params - HasLoop
Body - HasModule
Item - HasName
- HasType
Bounds - HasVisibility
- IsString
- Range
Item - Trait to describe operations common to both
RangeExprandRangePat.
Functionsยง
- attrs_
including_ inner - attrs_
with_ doc_ including_ inner - Returns all attributes of this node, including inner attributes that may not be directly under this node but under a child.