Module marker_api::ast
source · Expand description
A module containing the AST of Marker, which is the main syntactic representation of the written code.
Structs
- An expression constructing an array.
- The syntactic representation of an array with a known size like:
[T; N]
- An expression assigning a value to an assignee expression.
AstPath
s are used to identify items. A qualified path (QPath
) can be used in expressions and types to identify associated items on types. For traits it’s additionally possible to specify the type that should be used asSelf
. This is sometimes needed to disambiguate an item, if it exists both as an associated item on a type, and as an associated item on traits, that this type implements.- An
.await
expression on a future, like: - A generic bound in form
<identifier=type>
. For example,Item=i32
would be the generic binding here: - A block expression is one of the most fundamental expressions in Rust. It is used by items and expressions to group statements together and express scopes.
- A body represents the expression of items.
- The syntactic representation of the
bool
type. - A break expression with an optional label and an optional value.
- A call expression calling a function. The called function is identified using an expression, called operand. The following shows a few examples of call expressions:
- A closure expression
- A parameter for a
ClosureExpr
, with a pattern and an optional type, like: - A constant expression as an argument for a constant generic.
- An expression that is evaluated at compile time. These show up in array indices and constant generics.
- A const item like:
- A constant parameter with an optional constant value, like this:
- A continue expression with an optional label.
- An expression used to construct structs, unions and enum variants. For tuple constructors, the field names will correspond to the field indices.
- A single field inside a
CtorExpr
. - An enum item like:
- An
extern
block with items like this: - An extern crate item like:
- An expression accessing a field or tuple index.
- A float literal like
1.0
,2e-2
,2_f32
. The results of float operations can be hardware-dependent. For exact value checks, it might be better to check the written float literal by getting the code snipped from the expression span. See: - A function item like:
- A parameter for a
FnItem
, like: - The syntactic representation of a function pointer, like
fn (T) -> U
- A parameter for the
FnPtrTy
. - A
for
loop iterating over values. - The syntactic representation of generic arguments for an item or path.
- This represents the generic parameters of a generic item. The bounds applied to the parameters in the declaration are stored as clauses in this struct.
- An impl item like:
- An index expression.
- A integer literal like
16
or8_u8
. All integer literals in Rust are unsigned numbers < 2^128. Negative numbers have a unary negation operation as their parent. - A single field inside a
StructItem
orUnionItem
with an identifier type and span. - A
let
expression used in conditional statements, to check if the value of the scrutinee matches the pattern. - A lifetime used as a generic argument or on a reference like this:
- The syntactic representation of a generic argument, like this:
- A lifetime parameter like the
'long
and'short: 'long
in: - A literal expression inside a pattern.
- An unconditional loop expression
- An arm inside a
MatchExpr
with an optional guard. - A match expression with a scrutinee and
MatchArm
s - A module item like:
- The syntactic representation of the never type
!
. - A type identified via a
AstQPath
. The kind and definition can be accessed via the ID returned byAstQPath::resolve()
. - Patterns are used as assignees in
AssignExpr
nodes. Assign expressions can target place expressions like variables,IndexExpr
s andFieldExpr
s. These expressions would be stored as this variant. - A range expression, like these:
- A range expression, like these:
- A return expression with an optional value.
- The syntactic representation of a variable length slice like
[T]
- A static item like:
- A pattern matching a field inside a
StructPat
instance. - A struct item like:
- A trait item like:
- The syntactic representation of a trait object.
- The
?
operator that unwraps valid values or propagates erroneous values to the calling function. - An expression used to construct a tuple.
- A type alias like:
- The syntactic representation of a generic argument, like this:
- A type parameter with optional bounds like
T
andU
in this example: - A union item like:
- A placeholder object for unstable items.
- A
use
declaration like: - The declared visibility of an item or field.
- A
while
loop expression
Enums
- A singular generic argument.
- A singular generic parameter, like
'a
andT
in this example: - This represents a single clause in a
where
statement
Traits
- This trait combines methods, which are common between all expressions.
- This trait combines methods, which are common between all items.
- This trait combines methods, which all patterns have in common.
- This trait combines methods, which all statements have in common.
- This trait is a collection of common information that is provided by all generic parameters.
- This trait combines methods, which are common between all syntactic types.