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

Support macro metavar expressions #11952

Closed
Veykril opened this issue Apr 10, 2022 · 2 comments
Closed

Support macro metavar expressions #11952

Veykril opened this issue Apr 10, 2022 · 2 comments
Labels
A-macro macro expansion C-feature Category: feature request

Comments

@Veykril
Copy link
Member

Veykril commented Apr 10, 2022

A subset is being stabilized soon rust-lang/rust#95860
RFC https://github.com/rust-lang/rfcs/blob/master/text/3086-macro-metavar-expr.md#dollar-dollar

@Veykril Veykril added A-macro macro expansion C-support Category: support questions labels Apr 10, 2022
@jonas-schievink jonas-schievink added C-feature Category: feature request and removed C-support Category: support questions labels Apr 10, 2022
@TimNN
Copy link
Contributor

TimNN commented May 31, 2022

At least for $$ the implementation seems to be pretty straight forward. If there's no-one else currently working on this, I'd like to take a stab at properly implementing the $$ support. (I still need to verify that the current behavior matches what rustc actually does, and especially if multiple levels of nesting behave correctly).

@Veykril
Copy link
Member Author

Veykril commented May 31, 2022

Go ahead!

TimNN added a commit to TimNN/rust-analyzer that referenced this issue Jun 2, 2022
bors added a commit that referenced this issue Jun 3, 2022
bors added a commit that referenced this issue Jul 11, 2022
feat: Implement `ignore`  and `index` metavar expression

Part of #11952

Fixes #12675
bors added a commit that referenced this issue May 28, 2023
Implement `${count()}` metavariable expression

This PR implements `${count()}` metavariable expression for MBE as described in [RFC 3086][rfc]. See [this section][sec-count] of the RFC for its semantics.

Additionally, this PR changes the type of depth parameter of `${index()}` from u32 to usize so as to match how [rustc parses it][index-usize].

Part of #11952
Fixes #14871

[rfc]: rust-lang/rfcs#3086
[sec-count]: https://github.com/rust-lang/rfcs/blob/master/text/3086-macro-metavar-expr.md#count
[index-usize]:https://github.com/rust-lang/rust/blob/ddad0576caf8d0515ed453e04b468977c7d3dfc1/compiler/rustc_expand/src/mbe/metavar_expr.rs#L22
@Veykril Veykril closed this as completed Jun 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macro macro expansion C-feature Category: feature request
Projects
None yet
Development

No branches or pull requests

3 participants