-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Tracking Issue for guard macro fragment specifier #153104
Copy link
Copy link
Open
Labels
A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: 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).Blocker: 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 RFCCategory: 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.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language team
Metadata
Metadata
Assignees
Labels
A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: 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).Blocker: 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 RFCCategory: 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.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language team
Type
Fields
Give feedbackNo fields configured for issues without a type.
This is a tracking issue for the feature "
guardmacro fragment specifier" accepted in #152832 (comment).The feature gate for the issue is
#![feature(macro_guard_matcher)].Introduce a new macro fragment specifier
guardto matchMatchArmGuard, to make it easier for macro authors to match the recently stabilizedif_let_guardfeature (#51114).This resolves #152313, because we either introduce a new
:guardmatcher or must refactormatches!andassert_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
:guardfragment specifier formacro_rulesanddecl_macroAdd macro matcher for
guardfragment specifier #153702:guardinmathces!andassert_matches!to supportif-letguardsUnresolved Questions
{really be in the follow set? I'm not quite sure it should.=>contrary to the conditions ofif&whileexpressions and the iterator offorloops which are expressions without struct expressions.if S {}successfully parses as an expression (namely asif (S) {}), macro matcher$g:guard {}currently rejectsif S {}as input because it parsesif (S {})and looks for extra{}which aren't there of course.Implementation history
matches!andassert_matches!#152832The initial attempt used
:ttto match if-let guards, but:ttgreedily captured the trailing comma and the assertion message. So we decide to introduce a new:guardmatcher.guardfragment specifier #153702