Skip to content

Commit aeedc20

Browse files
authored
Merge pull request #1580 from ehuss/2024-expr
Add `expr_2021` macro fragment specifier
2 parents 420e2bc + a5f20e3 commit aeedc20

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/macro-ambiguity.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ represent simple nonterminals with the given fragment specifier.
325325

326326
* FOLLOW(pat) = {`=>`, `,`, `=`, `|`, `if`, `in`}`.
327327

328-
* FOLLOW(expr) = FOLLOW(stmt) = {`=>`, `,`, `;`}`.
328+
* FOLLOW(expr) = FOLLOW(expr_2021) = FOLLOW(stmt) = {`=>`, `,`, `;`}`.
329329

330330
* FOLLOW(ty) = FOLLOW(path) = {`{`, `[`, `,`, `=>`, `:`, `=`, `>`, `>>`, `;`,
331331
`|`, `as`, `where`, block nonterminals}.

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)