Skip to content

Commit 3ad356a

Browse files
committed
2024: Update expr macro fragment specifier
1 parent da0f6da commit 3ad356a

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
@@ -138,8 +138,8 @@ r[macro.decl.meta.specifier]
138138
Valid fragment specifiers are:
139139

140140
* `block`: a [_BlockExpression_]
141-
* `expr`: an [_Expression_] except [_UnderscoreExpression_] and [_ConstBlockExpression_] (see [macro.decl.meta.expr-underscore])
142-
* `expr_2021`: same as `expr` (see [macro.decl.meta.edition2021])
141+
* `expr`: an [_Expression_]
142+
* `expr_2021`: an [_Expression_] except [_UnderscoreExpression_] and [_ConstBlockExpression_] (see [macro.decl.meta.edition2024])
143143
* `ident`: an [IDENTIFIER_OR_KEYWORD] or [RAW_IDENTIFIER]
144144
* `item`: an [_Item_]
145145
* `lifetime`: a [LIFETIME_TOKEN]
@@ -162,19 +162,15 @@ r[macro.decl.meta.dollar-crate]
162162
The keyword metavariable `$crate` can be used to refer to the current crate; see [Hygiene] below. Metavariables can be
163163
transcribed more than once or not at all.
164164

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

602598
[block labels]: expressions/loop-expr.md#labelled-block-expressions
603-
[const block]: expressions/block-expr.md#const-blocks
604599
[Hygiene]: #hygiene
605600
[IDENTIFIER]: identifiers.md
606601
[IDENTIFIER_OR_KEYWORD]: identifiers.md

0 commit comments

Comments
 (0)