rust-lang / rust-lang/rfcs

Add macro_rules fragment class for "expressions that can be followed by `{`"

Open
#1,463 14 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

T-lang
Dominant language
Markdown
Stars
6.6k
Forks
1.7k
Avg merge
16h 14m
Merged PRs (30d)
1

Description

(spawned off of https://github.com/rust-lang/rfcs/pull/1384#issuecomment-160165525 )

I've been leaving links to the above comment in all sorts of places, so I finally decided it was time to open an RFC issue for this idea.

Namely, to add some fragment class, which I'll call pred for now, that represents "the subset of expressions that do not have { in their follow set, and thus the presence of a { as the next token tells the parser that it is definitely done parsing the expression."

In particular, this is the subset of expressions that we use for the test in an if test { then } else { other }

Such an fragment class would be useful for writing macro_rules! that naturally want a { to come after them in the input pattern.

We used to superficially "allow" such macros, but they didn't actually work in general; see https://github.com/rust-lang/rust/issues/26739

Contributor guide

No contributing guide indexed for this repository

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 reading the linked RFC discussion and the referenced rust-lang/rust issue 26739 to understand the prior behavior and constraints. Done means reaching agreement on the proposed macro_rules fragment class and documenting the design sufficiently for an RFC or implementation to proceed.

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
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.