rust-lang / rust-lang/rust

Tracking Issue for `macro_named_capture_groups`

Open
#142,999 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-macros B-experimental C-tracking-issue S-tracking-unimplemented T-lang
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

This is a tracking issue for the RFC "Named macro capture groups" (rust-lang/rfcs#3649).
The feature gate for the issue is #![feature(macro_named_capture_groups)].

macro_rules! foo {
    ( $group1( $a:ident ),+ ) => {
        $group1( println!("{}", $a); )+
    }
}

This feature is currently experimental to figure out ideal behavior; an RFC has not yet been accepted.

About tracking issues

Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
Discussion comments will get marked as off-topic or deleted.
Repeated discussions on the tracking issue may lead to the tracking issue getting locked.

Steps
Unresolved Questions
  • What syntax should be used for groups?
    • $group(..) in the capture is nice, but $group(..) in the capture (expand the group) differs from $metavar(..) (expand a metavar followed by a new group) and context is needed to handle this correctly.
    • $'group was proposed to avoid this.
  • What syntax should be used for expanding the group in-place?
    • Standalone $group is nice but there is no way to expand the entire group and add parens after ($group (..) is ambiguous "expand group with parens" or "expand entire group, follow it by new parens")
    • $...group was proposed to avoid this.

XXX --- list all the "unresolved questions" found in the RFC to ensure they are
not forgotten

Implementation history

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 with RFC rust-lang/rfcs#3649 and the tracking issue's unresolved questions, then review the linked language-team discussion. The checklist indicates that done requires implementing the RFC, updating documentation, addressing style decisions, and eventually completing stabilization; no implementation file or test is named.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.