Skip to content

Tracking Issue for guard macro fragment specifier #153104

@SpriteOvO

Description

@SpriteOvO

This is a tracking issue for the feature "guard macro fragment specifier" accepted in #152832 (comment).
The feature gate for the issue is #![feature(macro_guard_matcher)].

Introduce a new macro fragment specifier guard to match MatchArmGuard, to make it easier for macro authors to match the recently stabilized if_let_guard feature (#51114).

This resolves #152313, because we either introduce a new :guard matcher or must refactor matches! and assert_matches! into built-in macros. Considering that more users will benefit from :guard, we choose to do so.

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

  • (fmease writing) Should { really be in the follow set? I'm not quite sure it should.
    • The condition of match guards can be an "unrestricted" expressions precisely because the guard can only be followed by => contrary to the conditions of if & while expressions and the iterator of for loops which are expressions without struct expressions.
    • So while if S {} successfully parses as an expression (namely as if (S) {}), macro matcher $g:guard {} currently rejects if S {} as input because it parses if (S {}) and looks for extra { } which aren't there of course.

Implementation history

Metadata

Metadata

Assignees

Labels

A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)B-experimentalBlocker: In-tree experiment; RFC pending, not yet approved or unneeded (requires FCP to stabilize).C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language team

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions