pub enum RirPattern {
Wildcard(Span),
Int(i64, Span),
Bool(bool, Span),
Path {
module: Option<InstRef>,
type_name: Spur,
variant: Spur,
span: Span,
},
DataVariant {
module: Option<InstRef>,
type_name: Spur,
variant: Spur,
bindings: Vec<RirPatternBinding>,
span: Span,
},
StructVariant {
module: Option<InstRef>,
type_name: Spur,
variant: Spur,
field_bindings: Vec<RirStructPatternBinding>,
span: Span,
},
Ident {
name: Spur,
is_mut: bool,
span: Span,
},
Tuple {
elems: Vec<RirPattern>,
rest_position: Option<u32>,
span: Span,
},
Struct {
module: Option<InstRef>,
type_name: Spur,
fields: Vec<RirStructField>,
has_rest: bool,
span: Span,
},
ComptimeUnrollArm {
binding: Spur,
iterable: InstRef,
span: Span,
},
}Expand description
A pattern in a match expression (RIR level - untyped).
Recursive shape introduced by ADR-0051 Phase 4: Ident, Tuple, and
Struct variants let astgen carry source-level nesting straight to sema
instead of pre-elaborating tuple/struct match roots. The existing
variant-pattern shapes (DataVariant, StructVariant) are unchanged;
nested sub-patterns inside variant fields still go through the
elaboration layer until a follow-up RIR migration replaces their flat
bindings with RirPattern leaves.
Variants§
Wildcard(Span)
Wildcard pattern _ - matches anything
Int(i64, Span)
Integer literal pattern (can be positive or negative)
Bool(bool, Span)
Boolean literal pattern
Path
Path pattern for enum variants (e.g., Color::Red or module.Color::Red)
Fields
module: Option<InstRef>Optional module reference for qualified paths (e.g., the module in module.Color::Red)
type_name: SpurThe enum type name
variant: SpurThe variant name
span: SpanSpan of the pattern
DataVariant
Data variant pattern with field bindings (e.g., Option::Some(x))
Fields
type_name: SpurThe enum type name
variant: SpurThe variant name
bindings: Vec<RirPatternBinding>Bindings for each field
span: SpanSpan of the pattern
StructVariant
Struct variant pattern with named field bindings (e.g., Shape::Circle { radius })
Fields
type_name: SpurThe enum type name
variant: SpurThe variant name
field_bindings: Vec<RirStructPatternBinding>Named field bindings
span: SpanSpan of the pattern
Ident
Name binding x or mut x (ADR-0051). Used at the arm root or as
a sub-pattern inside Tuple / Struct. Equivalent to x @ _.
Tuple
Tuple pattern (p0, p1, ...) (ADR-0051). elems carries the
explicit sub-patterns only; rest_position records where a ..
rest marker appeared so sema can expand it to wildcards filling
the scrutinee’s arity. None means no rest; Some(i) means the
rest was written at source index i (so elems[..i] are the
prefix and elems[i..] the suffix).
Struct
Named-struct pattern TypeName { field: pat, .. } (ADR-0051).
has_rest marks an explicit .. trailing the field list.
ComptimeUnrollArm
ADR-0079 Phase 3: a comptime_unroll for arm template. Sema
evaluates iterable at comptime, synthesizes one regular arm
per element, and substitutes binding as a comptime value in
the arm body. Only valid at the top level of a match arm.
Implementations§
Source§impl RirPattern
impl RirPattern
Trait Implementations§
Source§impl Clone for RirPattern
impl Clone for RirPattern
Source§fn clone(&self) -> RirPattern
fn clone(&self) -> RirPattern
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RirPattern
impl Debug for RirPattern
Source§impl<'de> Deserialize<'de> for RirPattern
impl<'de> Deserialize<'de> for RirPattern
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for RirPattern
impl RefUnwindSafe for RirPattern
impl Send for RirPattern
impl Sync for RirPattern
impl Unpin for RirPattern
impl UnsafeUnpin for RirPattern
impl UnwindSafe for RirPattern
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,
§impl<'src, T> IntoMaybe<'src, T> for Twhere
T: 'src,
impl<'src, T> IntoMaybe<'src, T> for Twhere
T: 'src,
§impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
§type Iter<'a> = Once<&'a T>
where
T: 'a
type Iter<'a> = Once<&'a T> where T: 'a
§fn contains(&self, val: &T) -> boolwhere
T: PartialEq,
fn contains(&self, val: &T) -> boolwhere
T: PartialEq,
§fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>where
'p: 'b,
fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>where
'p: 'b,
MaybeRef].