Skip to main content

Arch

Enum Arch 

Source
#[non_exhaustive]
pub enum Arch<K> {
Show 98 variants Module { name: Pick<K>, items: Pick<K>, }, Pass { inner: Pick<K>, }, Splice { items: Pick<K>, }, Unsupported, Let { pat: Pick<K>, ty: Pick<K>, init: Pick<K>, else_: Pick<K>, mutable: bool, hoist: bool, }, ExprStmt { expr: Pick<K>, }, Defer { body: Pick<K>, }, Static { name: Pick<K>, ty: Pick<K>, init: Pick<K>, }, GlobalDecl { names: Pick<K>, }, Import { path: Pick<K>, alias: Pick<K>, }, UseTree { path: Pick<K>, alias: Pick<K>, children: Pick<K>, }, Fn { name: Pick<K>, generics: Pick<K>, params: Pick<K>, ret: Pick<K>, throws: Pick<K>, body: Pick<K>, where_: Pick<K>, }, Record { name: Pick<K>, generics: Pick<K>, fields: Pick<K>, shape: RecordShape, }, Sum { name: Pick<K>, generics: Pick<K>, variants: Pick<K>, }, Interface { name: Pick<K>, generics: Pick<K>, supers: Pick<K>, items: Pick<K>, }, Class { name: Pick<K>, generics: Pick<K>, bases: Pick<K>, interfaces: Pick<K>, members: Pick<K>, mixin: bool, }, Impl { generics: Pick<K>, interface: Pick<K>, self_ty: Pick<K>, items: Pick<K>, }, Alias { name: Pick<K>, generics: Pick<K>, ty: Pick<K>, }, AssocType { name: Pick<K>, bounds: Pick<K>, default: Pick<K>, }, Const { name: Pick<K>, ty: Pick<K>, value: Pick<K>, }, GlobalVar { name: Pick<K>, ty: Pick<K>, init: Pick<K>, mutable: bool, }, MixinUse { mixins: Pick<K>, rules: Pick<K>, }, MixinRule { from: Pick<K>, method: Pick<K>, insteadof: Pick<K>, alias: Pick<K>, }, FieldDecl { name: Pick<K>, ty: Pick<K>, default: Pick<K>, }, VariantDecl { name: Pick<K>, fields: Pick<K>, discriminant: Pick<K>, shape: RecordShape, }, GenericParam { name: Pick<K>, bounds: Pick<K>, ty: Pick<K>, default: Pick<K>, }, WherePred { subject: Pick<K>, bounds: Pick<K>, }, Param { pat: Pick<K>, ty: Pick<K>, default: Pick<K>, }, Capture { name: Pick<K>, }, Path { segments: Pick<K>, global: Pick<K>, qself: Pick<K>, qtrait: Pick<K>, }, Segment { name: Pick<K>, args: Pick<K>, }, AssocBinding { name: Pick<K>, ty: Pick<K>, }, Unary { op: Pick<K>, operand: Pick<K>, }, Binary { lhs: Pick<K>, op: Pick<K>, rhs: Pick<K>, }, Postfix { operand: Pick<K>, op: Pick<K>, }, Assign { target: Pick<K>, op: Pick<K>, value: Pick<K>, }, RefAssign { target: Pick<K>, source: Pick<K>, }, Call { callee: Pick<K>, args: Pick<K>, }, Arg { name: Pick<K>, value: Pick<K>, }, Member { base: Pick<K>, member: Pick<K>, args: Pick<K>, call: Pick<K>, }, MethodCall { receiver: Pick<K>, method: Pick<K>, generics: Pick<K>, args: Pick<K>, }, DynMember { base: Pick<K>, name: Pick<K>, args: Pick<K>, call: Pick<K>, }, Index { base: Pick<K>, index: Pick<K>, }, VarVar { inner: Pick<K>, }, Append { base: Pick<K>, }, Tuple { elems: Pick<K>, }, Array { elems: Pick<K>, }, Map { entries: Pick<K>, }, MapEntry { key: Pick<K>, value: Pick<K>, }, RecordLit { path: Pick<K>, fields: Pick<K>, base: Pick<K>, }, FieldInit { name: Pick<K>, value: Pick<K>, }, Repeat { elem: Pick<K>, count: Pick<K>, }, Cast { expr: Pick<K>, ty: Pick<K>, }, Borrow { expr: Pick<K>, }, Deref { inner: Pick<K>, }, Block { stmts: Pick<K>, tail: Pick<K>, label: Pick<K>, tail_from_last: bool, }, If { cond: Pick<K>, then: Pick<K>, else_: Pick<K>, }, Match { scrutinee: Pick<K>, arms: Pick<K>, }, Arm { pat: Pick<K>, guard: Pick<K>, body: Pick<K>, }, Loop { label: Pick<K>, body: Pick<K>, }, Break { label: Pick<K>, value: Pick<K>, }, Continue { label: Pick<K>, }, Return { value: Pick<K>, }, Throw { value: Pick<K>, }, Try { body: Pick<K>, catches: Pick<K>, finally: Pick<K>, }, Catch { types: Pick<K>, name: Pick<K>, body: Pick<K>, }, Await { inner: Pick<K>, }, Yield { key: Pick<K>, value: Pick<K>, }, YieldFrom { inner: Pick<K>, }, Spawn { inner: Pick<K>, }, Closure { params: Pick<K>, ret: Pick<K>, captures: Pick<K>, body: Pick<K>, implicit: Option<CaptureMode>, }, Template(TemplateUse), Interp { parts: Pick<K>, close: Pick<K>, join: Join, }, Attr { name: Pick<K>, args: Pick<K>, }, AttrArg { key: Pick<K>, value: Pick<K>, }, WildPat, RestPat { bind: Pick<K>, }, BindPat { name: Pick<K>, sub: Pick<K>, }, TuplePat { elems: Pick<K>, }, CtorPat { path: Pick<K>, elems: Pick<K>, }, RecordPat { path: Pick<K>, fields: Pick<K>, }, FieldPat { name: Pick<K>, pat: Pick<K>, }, OrPat { alts: Pick<K>, }, RangePat { lo: Pick<K>, hi: Pick<K>, }, RefPat { inner: Pick<K>, }, SlicePat { elems: Pick<K>, }, TypeTestPat { ty: Pick<K>, pat: Pick<K>, }, TupleTy { elems: Pick<K>, }, ArrayTy { elem: Pick<K>, len: Pick<K>, }, SliceTy { elem: Pick<K>, }, RefTy { inner: Pick<K>, region: Pick<K>, }, PtrTy { inner: Pick<K>, }, NullableTy { inner: Pick<K>, }, FnTy { params: Pick<K>, ret: Pick<K>, }, ObjectTy { bounds: Pick<K>, }, ImplTy { bounds: Pick<K>, }, UnionTy { members: Pick<K>, }, IntersectionTy { members: Pick<K>, },
}
Expand description

A semantic archetype: what a syntax node means, and where its parts are.

A Mapping maps node kinds to archetypes. Lowering a node lowers each field in the context the archetype gives it (an If’s cond as an expression, a Fn’s params as parameters) and builds the HIR form. Fields marked required that a node lacks become error nodes plus a MissingField problem; the others are simply left out. List fields take every match of their pick.

The modifiers each archetype reads from its direct children are listed with it (see Modifier).

§Examples

use lower_lang::{Arch, Pick};

// `if COND BLOCK (else (if_expr | BLOCK))?` with no field labels:
let if_expr: Arch<u16> = Arch::If {
    cond: Pick::NthNode(0),
    then: Pick::NthNode(1),
    else_: Pick::NthNode(2),
};
assert!(matches!(if_expr, Arch::If { .. }));

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Module

A module: the root of a file, or a nested module. Declarations among items become the module’s items; everything else (statements and expressions) becomes its top-level body, in order (scripts, REPL entries, conditional definitions).

Fields

§name: Pick<K>

The module’s name (nested modules).

§items: Pick<K>

List: declarations and top-level statements.

§

Pass

A wrapper with one meaningful child (expr, a parenthesized group, a statement wrapper): lowered as that child, in the same context.

Fields

§inner: Pick<K>

Required: the child.

§

Splice

Several statements, items, or class members from one node (let a = 1, b = 2;), spliced into the enclosing list.

Fields

§items: Pick<K>

List: the parts, lowered in the enclosing list’s context.

§

Unsupported

A construct the language has but does not lower yet: an error node plus an Unsupported problem.

§

Let

let PAT: TY = INIT else ELSE; — binds the pattern’s names for the following statements. Modifiers: Mut makes the binders mutable.

Fields

§pat: Pick<K>

Required: the pattern (an identifier binds it).

§ty: Pick<K>

The annotation.

§init: Pick<K>

The initializer.

§else_: Pick<K>

The diverging else of let-else.

§mutable: bool

Whether the binders are mutable without a Mut modifier (var, JavaScript let) rather than only with one (let / let mut).

§hoist: bool

Function-scoped hoisting (JavaScript var): the name is declared once at the top of the enclosing function (or module body) and this statement becomes an assignment. Any other pattern (var [a, b] = x) binds hygienic temporaries that are assigned to the hoisted names right after it matches; a by-reference binding cannot be hoisted this way and is reported (CannotHoist).

§

ExprStmt

EXPR; — an expression evaluated for its effect (never a block tail).

Fields

§expr: Pick<K>

Required: the expression.

§

Defer

defer BODY — runs when the enclosing block exits.

Fields

§body: Pick<K>

Required: the deferred expression.

§

Static

static $x = INIT; — a function-static variable (PHP, C).

Fields

§name: Pick<K>

Required: the variable’s name.

§ty: Pick<K>

The annotation.

§init: Pick<K>

The initializer.

§

GlobalDecl

global $a, $b; — locals aliasing globals, one statement per name.

Fields

§names: Pick<K>

List: the names.

§

Import

use a::b as c; / use a::*; — an import item. Modifiers: Glob.

Fields

§path: Pick<K>

Required: the imported path (a path node or one name).

§alias: Pick<K>

The alias (as c).

§

UseTree

A use tree: use a::{b, c::{d, e as f}, g::*}; (Rust), use App\{Foo, Bar as Baz}; (PHP group use). Flattened into one HIR import per leaf, each path the concatenation of the prefixes above it. Modifiers: visibility (on the outermost tree, for every import it makes), Glob (a * leaf).

The expected tree: a use-tree node holds an optional prefix path (a path node or one name), then either nested children (use-tree nodes, names, or paths; container nodes such as { ... } splice) or, for a leaf, an optional alias. A child spelled self (a token in the root table mapping to PathRoot::SelfModule) imports the prefix itself. Leading root tokens of the outermost prefix (::, crate, super) set the import’s root. The walk is iterative; nesting depth is bounded only by the tree.

Fields

§path: Pick<K>

The prefix (or, for a leaf, the whole path).

§alias: Pick<K>

A leaf’s alias (as f).

§children: Pick<K>

List: the nested trees of a group.

§

Fn

A function. Modifiers: visibility, Async, Generator, Throws, Unsafe. In a class, interface, or impl it is a method.

Fields

§name: Pick<K>

Required: the name.

§generics: Pick<K>

List: generic parameters.

§params: Pick<K>

List: parameters.

§ret: Pick<K>

The declared return type.

§throws: Pick<K>

The declared thrown type.

§body: Pick<K>

The body (absent for required, abstract, or foreign functions).

§where_: Pick<K>

List: where-clause predicates.

§

Record

A record (struct) or union. Modifiers: visibility, Union.

Fields

§name: Pick<K>

Required: the name.

§generics: Pick<K>

List: generic parameters.

§fields: Pick<K>

List: the fields.

§shape: RecordShape

How the field layout is decided.

§

Sum

A sum (enum) with variants. Modifiers: visibility.

Fields

§name: Pick<K>

Required: the name.

§generics: Pick<K>

List: generic parameters.

§variants: Pick<K>

List: the variants.

§

Interface

An interface or trait. Modifiers: visibility.

Fields

§name: Pick<K>

Required: the name.

§generics: Pick<K>

List: generic parameters.

§supers: Pick<K>

List: super-interfaces (types).

§items: Pick<K>

List: members (methods, constants, associated types).

§

Class

A class. Modifiers: visibility, Abstract, Final.

Fields

§name: Pick<K>

Required: the name.

§generics: Pick<K>

List: generic parameters.

§bases: Pick<K>

List: base classes, in method-resolution order (types).

§interfaces: Pick<K>

List: implemented interfaces (types).

§members: Pick<K>

List: members: fields, methods, constants, static fields, aliases, mixin uses.

§mixin: bool

A mixin (PHP trait): never instantiated, used by classes.

§

Impl

An implementation block (impl Tr for T { ... }).

Fields

§generics: Pick<K>

List: generic parameters.

§interface: Pick<K>

The implemented interface (a type).

§self_ty: Pick<K>

Required: the implementing type.

§items: Pick<K>

List: members.

§

Alias

A type alias. Modifiers: visibility.

Fields

§name: Pick<K>

Required: the name.

§generics: Pick<K>

List: generic parameters.

§ty: Pick<K>

Required: the aliased type.

§

AssocType

An associated type declared by an interface.

Fields

§name: Pick<K>

Required: the name.

§bounds: Pick<K>

List: bounds (types).

§default: Pick<K>

A default type.

§

Const

A compile-time constant. Modifiers: visibility.

Fields

§name: Pick<K>

Required: the name.

§ty: Pick<K>

The annotation.

§value: Pick<K>

The value (absent only in an interface).

§

GlobalVar

A global or static variable item. Modifiers: visibility, Mut.

Fields

§name: Pick<K>

Required: the name.

§ty: Pick<K>

The annotation.

§init: Pick<K>

The initializer.

§mutable: bool

Whether it is assignable without a Mut modifier.

§

MixinUse

A mixin use inside a class (PHP use T, U { rules }).

Fields

§mixins: Pick<K>

List: the mixins (types).

§rules: Pick<K>

List: conflict-resolution rules (MixinRule nodes).

§

MixinRule

One rule of a mixin use: T::hello insteadof U, V; or T::hello as protected greet; / hello as private;. With insteadof types it is an exclusion; otherwise an alias, with a new name, a visibility modifier (Public, Protected, Private), or both. A rule with neither is reported (MissingField action).

Fields

§from: Pick<K>

The mixin the method comes from (T in T::hello), a type.

§method: Pick<K>

Required: the method’s name.

§insteadof: Pick<K>

List: the mixins it is taken instead of (types).

§alias: Pick<K>

The new name of an alias.

§

FieldDecl

A field of a record, variant, or class. Modifiers: visibility; in a class, Static makes it a static (global) member instead.

Fields

§name: Pick<K>

The name (absent for a positional field).

§ty: Pick<K>

The type.

§default: Pick<K>

A default value.

§

VariantDecl

A variant of a sum.

Fields

§name: Pick<K>

Required: the name.

§fields: Pick<K>

List: the fields.

§discriminant: Pick<K>

An explicit discriminant.

§shape: RecordShape

How the field layout is decided.

§

GenericParam

A generic parameter: a type parameter, a const parameter (with a type), or a region (a lifetime-role token).

Fields

§name: Pick<K>

Required: the name.

§bounds: Pick<K>

List: bounds (types).

§ty: Pick<K>

The type of a const parameter.

§default: Pick<K>

A default (a type, or a constant for a const parameter).

§

WherePred

A where-clause predicate: T: A + B.

Fields

§subject: Pick<K>

Required: the constrained type.

§bounds: Pick<K>

List: the bounds (types).

§

Param

A parameter. Modifiers: Ref (by reference, PHP &$x), Mut, Rest (variadic), RestNamed, NamedOnly, PositionalOnly, Receiver.

Fields

§pat: Pick<K>

Required: the pattern (usually one name).

§ty: Pick<K>

The annotation.

§default: Pick<K>

The default value.

§

Capture

An explicit closure capture (PHP use ($x, &$y)). Modifiers: Ref, Mut.

Fields

§name: Pick<K>

Required: the captured name.

§

Path

A path: a::b::c, ::a, self::a, super::a, Self::a, <T as Tr>::a. Leading tokens of segments whose kind is in the mapping’s root table set the root.

Fields

§segments: Pick<K>

Required (unless qualified): list of segments (names or Segment nodes).

§global: Pick<K>

A leading global marker (::a).

§qself: Pick<K>

The qualified self type (<T as ...>).

§qtrait: Pick<K>

List: the trait segments of a qualified self (<T as a::Tr>).

§

Segment

A path segment with generic arguments (Vec::<i32>).

Fields

§name: Pick<K>

Required: the name.

§args: Pick<K>

List: generic arguments.

§

AssocBinding

An associated-type binding in generic arguments: Item = u8.

Fields

§name: Pick<K>

Required: the associated type’s name.

§ty: Pick<K>

Required: its type.

§

Unary

A prefix operator; the operator token’s kind is looked up in the prefix operator table.

Fields

§op: Pick<K>

Required: the operator token.

§operand: Pick<K>

Required: the operand.

§

Binary

A binary operator; the token’s kind is looked up in the binary operator table. &&, ||, ??, assignment, and compound assignment are operators too.

Fields

§lhs: Pick<K>

Required: the left operand.

§op: Pick<K>

Required: the operator token.

§rhs: Pick<K>

Required: the right operand.

§

Postfix

A postfix operator; looked up in the postfix operator table.

Fields

§operand: Pick<K>

Required: the operand.

§op: Pick<K>

Required: the operator token.

§

Assign

TARGET = VALUE or TARGET op= VALUE; a compound operator token is looked up in the binary operator table.

Fields

§target: Pick<K>

Required: the place.

§op: Pick<K>

The operator token (absent: plain assignment).

§value: Pick<K>

Required: the value.

§

RefAssign

$a = &$b: reference assignment (PHP).

Fields

§target: Pick<K>

Required: the place that becomes an alias.

§source: Pick<K>

Required: the aliased place.

§

Call

A call.

Fields

§callee: Pick<K>

Required: the callee.

§args: Pick<K>

List: arguments.

§

Arg

A call argument: named (name: value), spread (...xs, modifier Spread; **kw, modifier SpreadNamed), or a place (&$x, modifier Ref). Plain expressions in an argument list need no archetype.

Fields

§name: Pick<K>

The argument’s name.

§value: Pick<K>

Required: the value.

§

Member

Member access, or a method call when call finds something: a.b, a.0, a.b(x).

Fields

§base: Pick<K>

Required: the accessed value.

§member: Pick<K>

Required: the member (a name, or a number for tuple fields).

§args: Pick<K>

List: method-call arguments.

§call: Pick<K>

The call marker (such as (); Absent means never a call.

§

MethodCall

A method call with explicit generic arguments: x.f::<T>(a).

Fields

§receiver: Pick<K>

Required: the receiver.

§method: Pick<K>

Required: the method name.

§generics: Pick<K>

List: generic arguments.

§args: Pick<K>

List: arguments.

§

DynMember

$o->$name / $o->$name(args): a member chosen at run time (Mox).

Fields

§base: Pick<K>

Required: the accessed value.

§name: Pick<K>

Required: the member name, an expression.

§args: Pick<K>

List: method-call arguments.

§call: Pick<K>

The call marker; Absent means never a call.

§

Index

base[index].

Fields

§base: Pick<K>

Required: the indexed value.

§index: Pick<K>

Required: the index.

§

VarVar

$$name: the variable named at run time (Mox).

Fields

§inner: Pick<K>

Required: the expression naming the variable.

§

Append

$a[]: append position (Mox); only a write target.

Fields

§base: Pick<K>

Required: the array.

§

Tuple

(a, b).

Fields

§elems: Pick<K>

List: elements.

§

Array

[a, b].

Fields

§elems: Pick<K>

List: elements.

§

Map

An ordered map literal: [k => v, w] (PHP arrays). Elements that are not MapEntry nodes take the next index.

Fields

§entries: Pick<K>

List: entries.

§

MapEntry

key => value inside a map literal.

Fields

§key: Pick<K>

The key (absent: next index).

§value: Pick<K>

Required: the value.

§

RecordLit

Path { x: 1, ..base } or an anonymous record.

Fields

§path: Pick<K>

The record type’s path.

§fields: Pick<K>

List: field initializers.

§base: Pick<K>

The ..base expression.

§

FieldInit

name: value (or the shorthand name) in a record literal.

Fields

§name: Pick<K>

Required: the field name.

§value: Pick<K>

The value (absent: shorthand, the variable of the same name).

§

Repeat

[elem; count].

Fields

§elem: Pick<K>

Required: the element.

§count: Pick<K>

Required: the count.

§

Cast

expr as Type.

Fields

§expr: Pick<K>

Required: the converted value.

§ty: Pick<K>

Required: the target type.

§

Borrow

&expr / &mut expr. Modifiers: Mut.

Fields

§expr: Pick<K>

Required: the borrowed place.

§

Deref

*expr.

Fields

§inner: Pick<K>

Required: the dereferenced value.

§

Block

A block. Modifiers: Unsafe.

Fields

§stmts: Pick<K>

List: statements (and local items).

§tail: Pick<K>

The tail expression (the block’s value).

§label: Pick<K>

A label ('a: { ... }).

§tail_from_last: bool

Whether a final bare expression (not an expression statement) becomes the tail.

§

If

if cond then else.

Fields

§cond: Pick<K>

Required: the condition.

§then: Pick<K>

Required: the value when true.

§else_: Pick<K>

The value when false.

§

Match

match scrutinee { arms }.

Fields

§scrutinee: Pick<K>

Required: the matched value.

§arms: Pick<K>

List: arms.

§

Arm

A match arm: pat if guard => body.

Fields

§pat: Pick<K>

Required: the pattern.

§guard: Pick<K>

The guard.

§body: Pick<K>

Required: the body.

§

Loop

loop body — HIR’s one loop. while, do-while, C for, and for-each are templates.

Fields

§label: Pick<K>

A label.

§body: Pick<K>

Required: the body.

§

Break

break 'label value.

Fields

§label: Pick<K>

The target label.

§value: Pick<K>

The value.

§

Continue

continue 'label.

Fields

§label: Pick<K>

The target label.

§

Return

return value.

Fields

§value: Pick<K>

The value.

§

Throw

throw value.

Fields

§value: Pick<K>

Required: the raised value.

§

Try

try body catch... finally....

Fields

§body: Pick<K>

Required: the protected body.

§catches: Pick<K>

List: catch clauses (Catch or Arm nodes).

§finally: Pick<K>

The finally body.

§

Catch

catch (A | B $e) body: a type test (or an alternative of several) binding name. Without types it catches everything.

Fields

§types: Pick<K>

List: the caught types.

§name: Pick<K>

The bound name.

§body: Pick<K>

Required: the handler.

§

Await

await e.

Fields

§inner: Pick<K>

Required: the awaited value.

§

Yield

yield v, or yield k => v (PHP and Mox generators). A key without a value yields null under that key.

Fields

§key: Pick<K>

The explicit key.

§value: Pick<K>

The yielded value.

§

YieldFrom

yield from g: delegate to an inner generator or iterable; evaluates to its return value.

Fields

§inner: Pick<K>

Required: the inner generator or iterable.

§

Spawn

spawn e — starts a task running the callable e.

Fields

§inner: Pick<K>

Required: the callable.

§

Closure

A closure. Modifiers: Async, Generator, Throws.

Fields

§params: Pick<K>

List: parameters.

§ret: Pick<K>

The return type.

§captures: Pick<K>

List: explicit captures (Capture nodes or names).

§body: Pick<K>

Required: the body.

§implicit: Option<CaptureMode>

How outer variables are captured implicitly; None means only the explicit captures are visible (PHP function () use (...)).

§

Template(TemplateUse)

A node lowered through a template; see MappingBuilder::template_node.

§

Interp

An interpolated string: "Hello {$name}!", "$name", "{$a['k']}", and heredocs, as the lexer delivers them in segments.

The expected tree: the string’s node holds its pieces in order. Text pieces are tokens with role TokenRole::StrPart (no quotes; escapes decoded, adjacent pieces merged); every other selected element is an embedded expression ($name as a variable token, {$a['k']} as an index node; braces and quotes are skip kinds or left out by the parts pick). The parts are joined by join: one text piece alone is a string literal, no pieces the empty string, and a lone expression is joined with an empty string first, so the result is always a string conversion.

With close (a heredoc), close picks the closing-marker token: the whitespace before its identifier is removed from the start of every line of the text pieces (PHP 7.3+), a line indented less (or starting with an embedded expression) is reported (InvalidLiteral), and the newline before the marker is dropped.

Fields

§parts: Pick<K>

List: the pieces, in order.

§close: Pick<K>

A heredoc’s closing-marker token.

§join: Join

How the pieces become one string.

§

Attr

An attribute (#[Route("/home", methods: GET)], @inline), attached to the node it is a direct child of. Attribute nodes (and container nodes holding them, such as PHP’s #[A, B] group) are invisible to every other pick of that node. HIR attributes are data, never code (HIR spec §11): an argument value must be a literal or a name; anything else is reported (AttributeArgument) and left out.

Fields

§name: Pick<K>

Required: the attribute’s name, kept as written (a qualified name such as \App\Route keeps its separators).

§args: Pick<K>

List: the arguments (AttrArg nodes, or values).

§

AttrArg

key: value / key = value inside an attribute’s arguments.

Fields

§key: Pick<K>

The key.

§value: Pick<K>

The value (absent: a bare key).

§

WildPat

_ as a node.

§

RestPat

.. (or rest @ ..) inside a tuple, constructor, slice, or record pattern.

Fields

§bind: Pick<K>

A pattern binding the rest (slices only).

§

BindPat

ref mut x @ sub. Modifiers: Ref, Mut.

Fields

§name: Pick<K>

Required: the bound name.

§sub: Pick<K>

A sub-pattern the value must also match.

§

TuplePat

(a, b, ..).

Fields

§elems: Pick<K>

List: element patterns (a RestPat marks ..).

§

CtorPat

Some(x).

Fields

§path: Pick<K>

Required: the constructor’s path.

§elems: Pick<K>

List: element patterns.

§

RecordPat

Point { x, y: 0, .. }.

Fields

§path: Pick<K>

The record’s path (absent: an anonymous record or object).

§fields: Pick<K>

List: field patterns.

§

FieldPat

name: pat (or the shorthand name) in a record pattern.

Fields

§name: Pick<K>

Required: the field name.

§pat: Pick<K>

The pattern (absent: shorthand, binding the field’s name).

§

OrPat

a | b.

Fields

§alts: Pick<K>

List: alternatives.

§

RangePat

lo..hi / lo..=hi. Modifiers: Inclusive.

Fields

§lo: Pick<K>

The lower bound.

§hi: Pick<K>

The upper bound.

§

RefPat

&p / &mut p. Modifiers: Mut.

Fields

§inner: Pick<K>

Required: the inner pattern.

§

SlicePat

[a, b, rest @ .., z].

Fields

§elems: Pick<K>

List: element patterns (a RestPat marks ..).

§

TypeTestPat

e: Type / Type e — a type test, as in catch clauses.

Fields

§ty: Pick<K>

Required: the tested type.

§pat: Pick<K>

The pattern the value must then match.

§

TupleTy

(A, B).

Fields

§elems: Pick<K>

List: element types.

§

ArrayTy

[T; N].

Fields

§elem: Pick<K>

Required: the element type.

§len: Pick<K>

Required: the length.

§

SliceTy

[T].

Fields

§elem: Pick<K>

Required: the element type.

§

RefTy

&'r mut T. Modifiers: Mut.

Fields

§inner: Pick<K>

Required: the referent type.

§region: Pick<K>

An explicit region.

§

PtrTy

*mut T / *const T. Modifiers: Mut.

Fields

§inner: Pick<K>

Required: the pointee type.

§

NullableTy

T?.

Fields

§inner: Pick<K>

Required: the inner type.

§

FnTy

fn(A, B) -> R.

Fields

§params: Pick<K>

List: parameter types.

§ret: Pick<K>

The return type (absent: unit).

§

ObjectTy

dyn A + B.

Fields

§bounds: Pick<K>

List: bounds.

§

ImplTy

impl A + B.

Fields

§bounds: Pick<K>

List: bounds.

§

UnionTy

A | B | C (PHP union types). Members are lowered in source order; hir-lang’s finish puts them in canonical form (flattened, sorted, repeats dropped, null hoisted into Nullable, one member collapsed). No members at all is a MissingField problem.

Fields

§members: Pick<K>

List: the member types.

§

IntersectionTy

A & B (PHP intersection types), normalized like UnionTy.

Fields

§members: Pick<K>

List: the member types.

Implementations§

Source§

impl<K> Arch<K>

Source

pub const fn pass(n: u16) -> Self

Pass { inner: Nth(n) }: the common wrapper.

§Examples
use lower_lang::{Arch, Pick};

assert_eq!(Arch::<u8>::pass(1), Arch::Pass { inner: Pick::Nth(1) });
Source

pub const fn binary() -> Self

The shape of lang-forge’s operator nodes: binary is lhs op rhs.

§Examples
use lower_lang::{Arch, Pick};

let Arch::Binary { op, .. } = Arch::<u8>::binary() else { unreachable!() };
assert_eq!(op, Pick::Nth(1));
Source

pub const fn prefix() -> Self

The shape of lang-forge’s prefix nodes: op operand.

§Examples
use lower_lang::{Arch, Pick};

let Arch::Unary { operand, .. } = Arch::<u8>::prefix() else { unreachable!() };
assert_eq!(operand, Pick::Nth(1));
Source

pub const fn name(&self) -> &'static str

The archetype’s name, as problems and docs spell it.

§Examples
use lower_lang::Arch;

assert_eq!(Arch::<u8>::binary().name(), "binary");
assert_eq!(Arch::<u8>::WildPat.name(), "wildcard pattern");
Source

pub const fn lsf_name(&self) -> &'static str

The archetype’s LSF2 name: the value of arch = "…" in [semantics.bind] (LSF2 §15.4), and the key MappingBuilder::modifier_in takes. Archetypes LSF2 has no arch value for use the snake case of the variant (mixin_rule, use_tree, attr_arg, template).

§Examples
use lower_lang::{Arch, Pick};

let param: Arch<u8> = Arch::Param { pat: Pick::Nth(0), ty: Pick::Absent, default: Pick::Absent };
assert_eq!(param.lsf_name(), "param");
assert_eq!(Arch::<u8>::binary().lsf_name(), "binary");

Trait Implementations§

Source§

impl<K: Clone> Clone for Arch<K>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<K: Copy> Copy for Arch<K>

Source§

impl<K: Debug> Debug for Arch<K>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<K: Eq> Eq for Arch<K>

Source§

impl<K: Hash> Hash for Arch<K>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<K: PartialEq> PartialEq for Arch<K>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<K: PartialEq> StructuralPartialEq for Arch<K>

Auto Trait Implementations§

§

impl<K> Freeze for Arch<K>
where Pick<K>: Freeze,

§

impl<K> RefUnwindSafe for Arch<K>
where Pick<K>: RefUnwindSafe,

§

impl<K> Send for Arch<K>
where Pick<K>: Send,

§

impl<K> Sync for Arch<K>
where Pick<K>: Sync,

§

impl<K> Unpin for Arch<K>
where Pick<K>: Unpin,

§

impl<K> UnsafeUnpin for Arch<K>
where Pick<K>: UnsafeUnpin,

§

impl<K> UnwindSafe for Arch<K>
where Pick<K>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.