Skip to content

Commit e4ba8b0

Browse files
committed
Add expr_2021 macro fragment specifier
1 parent 420e2bc commit e4ba8b0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/macros-by-example.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ r[macro.decl.syntax]
3030
> &nbsp;&nbsp; | `$` `(` _MacroMatch_<sup>+</sup> `)` _MacroRepSep_<sup>?</sup> _MacroRepOp_
3131
>
3232
> _MacroFragSpec_ :\
33-
> &nbsp;&nbsp; &nbsp;&nbsp; `block` | `expr` | `ident` | `item` | `lifetime` | `literal`\
33+
> &nbsp;&nbsp; &nbsp;&nbsp; `block` | `expr` | `expr_2021` | `ident` | `item` | `lifetime` | `literal`\
3434
> &nbsp;&nbsp; | `meta` | `pat` | `pat_param` | `path` | `stmt` | `tt` | `ty` | `vis`
3535
>
3636
> _MacroRepSep_ :\
@@ -143,7 +143,8 @@ Valid fragment specifiers are:
143143
statements that require semicolons)
144144
* `pat_param`: a [_PatternNoTopAlt_]
145145
* `pat`: at least any [_PatternNoTopAlt_], and possibly more depending on edition
146-
* `expr`: an [_Expression_]
146+
* `expr`: an [_Expression_] except [_UnderscoreExpression_] and [_ConstBlockExpression_] (see [macro.decl.meta.expr-underscore])
147+
* `expr_2021`: same as `expr` (see [macro.decl.meta.edition2021])
147148
* `ty`: a [_Type_]
148149
* `ident`: an [IDENTIFIER_OR_KEYWORD] or [RAW_IDENTIFIER]
149150
* `path`: a [_TypePath_] style path
@@ -175,6 +176,8 @@ r[macro.decl.meta.edition2021]
175176
> Before the 2021 edition, they match exactly the same fragments as `pat_param` (that is, they accept [_PatternNoTopAlt_]).
176177
>
177178
> The relevant edition is the one in effect for the `macro_rules!` definition.
179+
>
180+
> The `expr_2021` fragment specifier exists to maintain backwards compatibility with editions before 2024.
178181
179182
## Repetitions
180183

@@ -572,6 +575,7 @@ For more detail, see the [formal specification].
572575
[Repetitions]: #repetitions
573576
[_Attr_]: attributes.md
574577
[_BlockExpression_]: expressions/block-expr.md
578+
[_ConstBlockExpression_]: expressions/block-expr.md#const-blocks
575579
[_DelimTokenTree_]: macros.md
576580
[_Expression_]: expressions.md
577581
[_Item_]: items.md

0 commit comments

Comments
 (0)