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

update fragment specifiers/allow spaces in metavariable declarations #49

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

youngspe
Copy link
Contributor

I came across a Rust project with macros that put a space after the colon in a macro metavariable declaration (e.g. $var: literal) and noticed the fragment specifier didn't get the variable.other.metavariable.specifier.rust scope. Additionally, pat_param isn't in the list so pat would get the scope but not _param. Plus Rust 2024 edition is adding an expr_2021 fragment specifier for backward compatibility with macros written for 2021 edition.


 

- Add `pat_param` specifier from 2021 edition
- Add `expr_2021` specifier from 2024 edition: https://doc.rust-lang.org/edition-guide/rust-2024/macro-fragment-specifiers.html
  - This specifier is currently unstable but the name seems to be confirmed: rust-lang/rust#123742 (comment)
- Require a word boundary (`\b`) at the end of the specifier
- Replace `[A-Za-z0-9_]` with `\w`
- Allow spaces before and after the `:` in metavariable declarations
- Add tests for the new specifiers and spacing
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.

1 participant