Skip to content

Commit 7b0c772

Browse files
committed
2024: Update expr macro fragment specifier
1 parent aeedc20 commit 7b0c772

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

src/macros-by-example.md

+5-10
Original file line numberDiff line numberDiff line change
@@ -143,8 +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_] except [_UnderscoreExpression_] and [_ConstBlockExpression_] (see [macro.decl.meta.expr-underscore])
147-
* `expr_2021`: same as `expr` (see [macro.decl.meta.edition2021])
146+
* `expr`: an [_Expression_]
147+
* `expr_2021`: an [_Expression_] except [_UnderscoreExpression_] and [_ConstBlockExpression_] (see [macro.decl.meta.edition2024])
148148
* `ty`: a [_Type_]
149149
* `ident`: an [IDENTIFIER_OR_KEYWORD] or [RAW_IDENTIFIER]
150150
* `path`: a [_TypePath_] style path
@@ -163,19 +163,15 @@ r[macro.decl.meta.dollar-crate]
163163
The keyword metavariable `$crate` can be used to refer to the current crate; see [Hygiene] below. Metavariables can be
164164
transcribed more than once or not at all.
165165

166-
r[macro.decl.meta.expr-underscore]
167-
For reasons of backwards compatibility, though `_` [is also an
168-
expression][_UnderscoreExpression_], a standalone underscore is not matched by
169-
the `expr` fragment specifier. However, `_` is matched by the `expr` fragment
170-
specifier when it appears as a subexpression.
171-
For the same reason, a standalone [const block] is not matched but it is matched when appearing as a subexpression.
172-
173166
r[macro.decl.meta.edition2021]
174167
> **Edition differences**: Starting with the 2021 edition, `pat` fragment-specifiers match top-level or-patterns (that is, they accept [_Pattern_]).
175168
>
176169
> Before the 2021 edition, they match exactly the same fragments as `pat_param` (that is, they accept [_PatternNoTopAlt_]).
177170
>
178171
> The relevant edition is the one in effect for the `macro_rules!` definition.
172+
173+
r[macro.decl.meta.edition2024]
174+
> **Edition differences**: Before the 2024 edition, `expr` fragment specifiers do not match [_UnderscoreExpression_] or [_ConstBlockExpression_] at the top level. They are allowed within subexpressions.
179175
>
180176
> The `expr_2021` fragment specifier exists to maintain backwards compatibility with editions before 2024.
181177
@@ -565,7 +561,6 @@ expansions, taking separators into account. This means:
565561

566562
For more detail, see the [formal specification].
567563

568-
[const block]: expressions/block-expr.md#const-blocks
569564
[Hygiene]: #hygiene
570565
[IDENTIFIER]: identifiers.md
571566
[IDENTIFIER_OR_KEYWORD]: identifiers.md

0 commit comments

Comments
 (0)