Skip to content

Commit

Permalink
Merge #494
Browse files Browse the repository at this point in the history
494: Macro called in pattern-without-range expand to a _single_ pattern r=Veykril a=scrabsha

The current specification says that a macro called in pattern context can expand to zero or more patterns.

I believe this is incorrect, as e.g. `0 1 _` is effectively 0 or more patterns, but is not a valid expansion ([playground link](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=86464c2a830b8d5550cd7947275d7dee)). Similarly, expanding to 0 patterns is invalid ([playground link](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=f56438b84bed3893105ba138af8913a6)).

As I understand it, the intent was to state that e.g. `0 | 1 | _` is a valid expansion for a pattern called in pattern context. As such, I changed the wording so that macro calls in pattern context must expand to a pattern, which matches `0 | 1 | _` and makes "expanding to zero patterns" invalid.

Co-authored-by: Sasha Pourcelot <[email protected]>
  • Loading branch information
bors-ferrocene[bot] and scrabsha authored May 16, 2024
2 parents 2082e80 + dcb55c1 commit b47e7cf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/macros.rst
Original file line number Diff line number Diff line change
Expand Up @@ -648,8 +648,8 @@ Macro Expansion

#. :dp:`fls_tu6kmwm4v9nj`
If the :t:`macro invocation` appears as part of a
:t:`pattern-without-range`, the output is required to constitute zero or
more :t:`[pattern]s`.
:t:`pattern-without-range`, the output is required to constitute a
:t:`[pattern]`.

#. :dp:`fls_3zn4dz19nyvq`
If the :t:`macro invocation` appears as part of a :t:`statement`, the
Expand Down

0 comments on commit b47e7cf

Please sign in to comment.