RustQ.Meta.Lower (rustq v1.0.0-rc.19)

Copy Markdown View Source

Lowers Rusty-Elixir to RustQ AST: expressions, statements, control flow, calls, and closures, with the borrows, ? propagation, and wrapping their expected types call for.

A body is first desugared by RustQ.Meta.Desugar and annotated by RustQ.Meta.Ownership. Lowering then hands parts to the modules beside it, which call back into lower_expr/2:

Summary

Functions

A closure argument, as a Rust closure argument: a name, or a binding pattern.

The item type of a list a comprehension builds.

The Rust path of an enum variant written as enum_variant(Enum, :variant).

Whether a collection is still in use after this use of it; see RustQ.Meta.Ownership.

The type of a variable in vars, or nil for another expression.

expression, lowered as an operand: a fallible one propagates its error with ?.

Lowers the body of a clause, expected to give type when known.

A closure taking args and returning body, as a value of expected_return_type when given.

A closure's body, lowered to return a value of expected_return_type when given.

Lowers an expression, as the RustQ.Meta.Lower.* modules lowering its parts call back.

A captured named function, as the Rust path of that function.

Lowers an expression in return position.

The Rust enum variant path an atom of an enum type names.

The Rust variant name an Elixir atom names, in Rust case.

Whether type is a slice or a reference to one.

The RustQ.Meta.Typing environment of a lowering context.

Functions

closure_arg!(other)

A closure argument, as a Rust closure argument: a name, or a binding pattern.

collection_item_type(type)

The item type of a list a comprehension builds.

enum_variant_path(path, variant)

The Rust path of an enum variant written as enum_variant(Enum, :variant).

enum_variant_path(path, variant, context)

function_body(body_ast, return_type, vars \\ %{}, opts \\ [])

@spec function_body(Macro.t(), RustQ.Meta.Type.t(), map(), keyword()) :: String.t()

in_use?(collection, context)

Whether a collection is still in use after this use of it; see RustQ.Meta.Ownership.

infer_expr_type(arg1, vars)

The type of a variable in vars, or nil for another expression.

lower_binary_operand(expression, context)

expression, lowered as an operand: a fallible one propagates its error with ?.

lower_clause_body(body, context)

Lowers the body of a clause, expected to give type when known.

lower_clause_body(body, context, expected_type)

lower_closure_args(args, body, context, expected_return_type \\ nil)

A closure taking args and returning body, as a value of expected_return_type when given.

lower_closure_body(body, expected_return_type, context)

A closure's body, lowered to return a value of expected_return_type when given.

lower_expr(expression, context)

Lowers an expression, as the RustQ.Meta.Lower.* modules lowering its parts call back.

lower_expr(expression, expected_type, context)

lower_function_capture(other, context)

A captured named function, as the Rust path of that function.

lower_return_expr(expression, return_type, context)

Lowers an expression in return position.

quoted_body(body_ast, return_type, vars \\ %{}, opts \\ [])

@spec quoted_body(Macro.t(), RustQ.Meta.Type.t() | nil, map(), keyword()) :: [
  struct()
]

rust_enum_variant(pattern, type)

The Rust enum variant path an atom of an enum type names.

rust_variant(name)

The Rust variant name an Elixir atom names, in Rust case.

slice_type?(type)

Whether type is a slice or a reference to one.

typing_env(context)

The RustQ.Meta.Typing environment of a lowering context.