@@ -30,7 +30,7 @@ r[macro.decl.syntax]
30
30
>   ;  ; | ` $ ` ` ( ` _ MacroMatch_ <sup >+</sup > ` ) ` _ MacroRepSep_ <sup >?</sup > _ MacroRepOp_
31
31
>
32
32
> _ MacroFragSpec_ :\
33
- >   ;  ;   ;  ; ` block ` | ` expr ` | ` ident ` | ` item ` | ` lifetime ` | ` literal ` \
33
+ >   ;  ;   ;  ; ` block ` | ` expr ` | ` expr_2021 ` | ` ident ` | ` item ` | ` lifetime ` | ` literal ` \
34
34
>   ;  ; | ` meta ` | ` pat ` | ` pat_param ` | ` path ` | ` stmt ` | ` tt ` | ` ty ` | ` vis `
35
35
>
36
36
> _ MacroRepSep_ :\
@@ -143,7 +143,8 @@ Valid fragment specifiers are:
143
143
statements that require semicolons)
144
144
* ` pat_param ` : a [ _ PatternNoTopAlt_ ]
145
145
* ` 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] )
147
148
* ` ty ` : a [ _ Type_ ]
148
149
* ` ident ` : an [ IDENTIFIER_OR_KEYWORD] or [ RAW_IDENTIFIER]
149
150
* ` path ` : a [ _ TypePath_ ] style path
@@ -175,6 +176,8 @@ r[macro.decl.meta.edition2021]
175
176
> Before the 2021 edition, they match exactly the same fragments as ` pat_param ` (that is, they accept [ _ PatternNoTopAlt_ ] ).
176
177
>
177
178
> 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.
178
181
179
182
## Repetitions
180
183
@@ -572,6 +575,7 @@ For more detail, see the [formal specification].
572
575
[ Repetitions ] : #repetitions
573
576
[ _Attr_ ] : attributes.md
574
577
[ _BlockExpression_ ] : expressions/block-expr.md
578
+ [ _ConstBlockExpression_ ] : expressions/block-expr.md#const-blocks
575
579
[ _DelimTokenTree_ ] : macros.md
576
580
[ _Expression_ ] : expressions.md
577
581
[ _Item_ ] : items.md
0 commit comments