Rust-GCC / Rust-GCC/gccrs

Pattern support

Open
#2,082 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
2.9k
Forks
231
Avg merge
19h 55m
Merged PRs (30d)
67

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 #2004)
  • nested tuple scrutinee match ((Foo::A, 1), ('c', Foo::B)) (handled in #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?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the dependencies in #2004 and #869, then use the unchecked pattern and match items as the scope. The issue names no source files or tests, so narrow the work to one remaining construct and define done as support for its stated example.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, rust
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.