Expand description
The core abstract syntax tree (AST) representation for hax.
This module defines the primary data structures used to represent typed syntax.
The design of this AST is designed under the following constraints:
- Valid (cargo check) pretty-printed Rust can be produced out of it.
- The Rust THIR AST from the frontend can be imported into this AST.
- The AST defined in the OCaml engine can be imported into this AST.
- This AST can be exported to the OCaml engine.
- This AST should be suitable for AST transformations.
Re-exports§
pub use identifiers::*;pub use traits::*;
Modules§
- diagnostics
- Diagnostic types used to represent and propagate errors (or warnings, notes, etc.) within the AST.
- fragment
- Enumeration types of any possible fragment of AST (
Fragment/FragmentRef). - identifiers
- Identifier types used throughout the AST.
- literals
- Literal and numeric type kinds used in constant expressions.
- resugared
- This module defines resugared fragments for the Hax Rust engine’s AST.
- span
- Source positions.
- traits
- Traits for utilities on AST data types
- utils
- This module provides a collection of utilities to work on AST.
- visitors
- Syntax tree traversals to walk a shared or mutable borrow of the syntax tree
of Hax. The visitors are generated using the
derive_generic_visitorlibrary.
Structs§
- Arm
- A pattern matching arm with metadata.
- Attribute
- Represents a single attribute.
- DynTrait
Goal - A
dyntrait. The generic arguments are known but the actual type implementing the trait is known dynamically. - Error
Node - Represent a node of the AST where an error occurred.
- Expr
- A typed expression with metadata.
- Generic
Param - A generic parameter (lifetime, type parameter or const parameter)
- Generics
- Generic parameters and constraints (contained between
<>in function declarations) - Guard
- A pattern matching arm guard with metadata.
- Impl
Expr - An
ImplExprdescribes the full data of a trait implementation. Because of generics, this may need to combine several concrete trait implementation items. For example,((1u8, 2u8), "hello").clone()combines the generic implementation ofClonefor(A, B)with the concrete implementations foru8and&str, represented as a tree. - Impl
Ident - Represents a trait bound in a generic constraint
- Impl
Item - Represents an impl item (associated type or function)
- Item
- A top-level item with metadata.
- Item
Quote Origin - The origin of a quote item.
- Loop
State - Represent explicit mutation context for a loop. This is useful to make loops pure.
- Metadata
- Extra information attached to syntax nodes.
- Module
- A “flat” module: this contains only non-module items.
- Param
- A function or closure parameter.
- Pat
- A typed pattern with metadata.
- Projection
Predicate - A projection predicate expresses a constraint over an associated type:
- Quote
- Represents an inlined piece of backend code
- Region
- Represent a Rust lifetime region.
- Spanned
Ty - A type with its associated span.
- Trait
Goal - Represents an instantiated trait that needs to be implemented.
- Trait
Item - Represents a trait item (associated type, fn, or default)
- Ty
- A indirection for the representation of types.
- Variant
- A variant of an enum or struct. In our representation structs always have one variant with an argument for each field.
Enums§
- Attribute
Kind - Represents the kind of an attribute.
- Binding
Mode - Binding modes used in patterns.
- Borrow
Kind - Represents different levels of borrowing.
- Control
Flow Kind - This is a marker to describe what control flow is present in a loop.
It is added by phase
DropReturnBreakContinueand the information is used inFunctionalizeLoops. We need it to replace the control flow nodes of the AST by an encoding in theControlFlowenum. - DocComment
Kind - Represents the kind of a doc comment.
- Expr
Kind - Describes the shape of an expression.
- Generic
Constraint - A generic constraint (lifetime, type-class or equality)
- Generic
Param Kind - Represents the kinds of generic parameters
- Generic
Value - Represents a generic value used in type applications (e.g.,
TinVec<T>). - Guard
Kind - Represents the various kinds of pattern guards.
- Impl
Expr Kind - Represents all the kinds of impl expr.
- Impl
Item Kind - Represents the kinds of impl items
- Item
Kind - A top-level item in the module.
- Item
Quote Origin Kind - The kind of a quote item’s origin
- Item
Quote Origin Position - The position of a quote item relative to its origin
- Lhs
- The left-hand side of an assignment.
- Loop
Kind - The kind of a loop (resugared by respective
Reconstruct...Loopsphases). Useful forFunctionalizeLoops. - PatKind
- Represents the various kinds of patterns.
- Primitive
Ty - Built-in primitive types.
- Quote
Content - A QuoteContent is a component of a quote: it can be a verbatim string, a Rust expression to embed in the quote, a pattern etc.
- Safety
Kind - Safety level of a function.
- Trait
Item Kind - Represents the kinds of trait items
- TyKind
- Describes any Rust type (e.g.,
i32,Vec<T>,fn(i32) -> bool).
Type Aliases§
- Attributes
- A list of attributes.