pub enum Shape {
Show 22 variants
Function,
Method,
Closure,
Record,
Impl,
Block,
Loop,
Branch,
Match,
MatchArm,
Call,
Assign,
VarDecl,
Return,
Break,
Continue,
Try,
ExprStmt,
MacroDef,
MacroCall,
Error,
Native(Lexeme),
}Expand description
The cross-language shape vocabulary.
Every variant except Shape::Native means the same thing in all three
languages, so structural comparison across files (and, in later phases,
across languages) can work on shapes alone. A frontend maps its grammar
onto these; whatever does not fit is carried as Shape::Native with the
grammar’s own kind name preserved.
Variants§
Function
A free function definition.
Method
A method definition (function inside an impl/class/struct body).
Closure
A closure or lambda.
Record
A record definition: struct, class, union or enum.
Impl
An implementation or member-definition container (impl, class body).
Block
A braced statement block.
Loop
A loop of any flavour (for, while, loop, do-while).
Branch
A two-way conditional (if/else chain member).
Match
A multi-way conditional (match, switch).
MatchArm
One arm of a multi-way conditional.
Call
A function, method or macro-like call expression.
Assign
An assignment or compound assignment.
VarDecl
A local variable declaration (let, C/C++ declaration statement).
Return
A return (or expression-position tail return).
Break
An early loop exit (break).
Continue
A loop continuation (continue).
Try
Error propagation or handling (? operator, try/catch).
ExprStmt
An expression used as a statement, not covered by a finer shape.
MacroDef
A macro or preprocessor definition site.
MacroCall
A macro invocation site (not expanded).
Error
A region the parser could not interpret. Children may still be intact.
Native(Lexeme)
A node kept under its native grammar kind because no common shape applies. The kind name takes part in structural comparison, so two native nodes match only when their grammars call them the same thing.
Implementations§
Source§impl Shape
impl Shape
Sourcepub const fn tag(&self) -> u8
pub const fn tag(&self) -> u8
A stable one-byte tag for this shape, for use as fingerprint input.
For Shape::Native the tag alone is not sufficient input: the
native kind name must be hashed alongside it, or all native nodes
would collapse into one shape.
Sourcepub const fn introduces_scope(&self) -> bool
pub const fn introduces_scope(&self) -> bool
Whether this shape opens a lexical scope for alpha renaming.
This is the structural basis normalization uses to rename identifiers consistently within — and only within — one scope. The judgement is syntactic and shared by all three languages: bodies bind, containers and single statements do not.
Sourcepub const fn is_statement(&self) -> bool
pub const fn is_statement(&self) -> bool
Whether nodes of this shape are statements for the purposes of statement sequences and statement-window fragments.
Trait Implementations§
impl Eq for Shape
impl StructuralPartialEq for Shape
Auto Trait Implementations§
impl Freeze for Shape
impl RefUnwindSafe for Shape
impl Send for Shape
impl Sync for Shape
impl Unpin for Shape
impl UnsafeUnpin for Shape
impl UnwindSafe for Shape
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.