Open
Description
Exhaustive list of what needs to be supported for patterns.
match:
- LiteralPattern
1
,'a'
- IdentifierPattern
e
- WildcardPattern
_
- PathPattern
- TuplePattern (done for multiple item type, remaining range item type
(1, 2, .., 10, 11)
) - StructPattern
- TupleStructPattern
- SlicePattern
[a, b, _]
- RangePattern
1..=5
- ReferencePattern
- RestPattern
..
- AltPattern
Foo::A | Foo::B
Match to-dos (done items not listed)
- path-to-tuple scrutinee (handled in hir: Compile
MatchExpr
to if statements #2004) - nested tuple scrutinee match
((Foo::A, 1), ('c', Foo::B))
(handled in hir: CompileMatchExpr
to if statements #2004) - struct scrutinee (i.e. non-enum ADT)
- match arm guards
Some(x) if x < 10
if let
and while let
are not yet implemented but they'll follow the same logic as match.
Once the refactor in #2004 is done, we'll be able to add support for if let and while let.
function params and let statements (refutable patterns omitted):
- IdentifierPattern
e
- WildcardPattern
_
- PathPattern
- TuplePattern
- StructPattern (TUPLE_PAT and IDENT_PAT item types remaining)
- TupleStructPattern (range items type remaining)
- SlicePattern
[a, b, _]
- ReferencePattern
- RestPattern
..
- AltPattern
Foo::A | Foo::B
Params and Vars to-dos:
- Irrefutability checks.
- what else?
patterns in for
loops cannot be added until #869 is finished.
additional to-dos:
- identifier pattern binding
-
ref
mut
identifier pattern handling - exhaustiveness/usefulness checks
Anything I forgot?
Metadata
Assignees
Labels
No labels