-
-
Notifications
You must be signed in to change notification settings - Fork 14.5k
Description
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
- Implement the
:guardfragment specifier formacro_rulesanddecl_macro - Use
:guardinmathces!andassert_matches!to supportif-letguards - Adjust documentation (see instructions on rustc-dev-guide)
- Stabilization PR (see instructions on rustc-dev-guide)
Unresolved Questions
None for now.
Implementation history
- Support if-let-guard in
matches!andassert_matches!#152832
The 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.