Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Macro called in pattern-without-range expand to a _single_ pattern #494

Merged
merged 1 commit into from
May 16, 2024

Conversation

scrabsha
Copy link
Contributor

@scrabsha scrabsha commented May 4, 2024

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). Similarly, expanding to 0 patterns is invalid (playground link).

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.

scrabsha added a commit to scrabsha/expandable that referenced this pull request May 5, 2024
Part of #29.

Things that are missing:
- Qualified paths in patterns (we don't support them at all)
- Macro calls.

Support for `#[expandable::pat]` has also been added.

I found a cool side-quest while working on this:
ferrocene/specification#494.

---------

Signed-off-by: Sasha Pourcelot <[email protected]>
@Hoverbear Hoverbear requested a review from pietroalbini May 9, 2024 16:19
@pietroalbini pietroalbini requested review from Veykril and removed request for pietroalbini May 16, 2024 13:10
@pietroalbini
Copy link
Member

Thanks! @Veykril could you take a look at this?

@Veykril
Copy link
Member

Veykril commented May 16, 2024

Nice catch, thanks!
bors merge

@bors-ferrocene
Copy link
Contributor

Build succeeded:

  • CI

@bors-ferrocene bors-ferrocene bot merged commit b47e7cf into ferrocene:main May 16, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants