-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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-metavar-expr
] Fix generated tokens hygiene
#95188
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rustbot
added
the
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
label
Mar 21, 2022
rust-highfive
added
the
S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
label
Mar 21, 2022
c410-f3r
force-pushed
the
aqui-vamos-nos
branch
from
March 21, 2022 22:46
441ac87
to
74e7313
Compare
@bors r+ rollup |
📌 Commit 74e7313 has been approved by |
bors
added
S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
and removed
S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
labels
Mar 22, 2022
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Mar 22, 2022
Rollup of 5 pull requests Successful merges: - rust-lang#95188 ([`macro-metavar-expr`] Fix generated tokens hygiene) - rust-lang#95196 (rename LocalState::Uninitialized to Unallocated) - rust-lang#95197 (Suggest constraining param for unary ops when missing trait impl) - rust-lang#95200 (Cancel a not emitted error after parsing const generic args) - rust-lang#95207 (update Termination trait docs) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
JohnTitor
added a commit
to JohnTitor/rust
that referenced
this pull request
Jun 9, 2022
…lett Stabilize `$$` in Rust 1.63.0 # Stabilization proposal This PR proposes the stabilization of a subset of `#![feature(macro_metavar_expr)]` or more specifically, the stabilization of dollar-dollar (`$$`). Tracking issue: rust-lang#83527 Version: 1.63 (2022-06-28 => beta, 2022-08-11 => stable). ## What is stabilized ```rust macro_rules! foo { () => { macro_rules! bar { ( $$( $$any:tt )* ) => { $$( $$any )* }; } }; } fn main() { foo!(); } ``` ## Motivation For more examples, see the [RFC](https://github.com/markbt/rfcs/blob/macro_metavar_expr/text/0000-macro-metavar-expr.md). Users must currently resort to a tricky and not so well-known hack to declare nested macros with repetitions. ```rust macro_rules! foo { ($dollar:tt) => { macro_rules! bar { ( $dollar ( $any:tt )* ) => { $dollar ( $any )* }; } }; } fn main() { foo!($); } ``` As seen above, such hack is fragile and makes work with declarative macros much more unpleasant. Dollar-dollar (`$$`), on the other hand, makes nested macros more intuitive. ## What isn't stabilized `count`, `ignore`, `index` and `length` are not being stabilized due to the lack of consensus. ## History * 2021-02-22, [RFC: Declarative macro metavariable expressions](rust-lang/rfcs#3086) * 2021-03-26, [Tracking Issue for RFC 3086: macro metavariable expressions](rust-lang#83527) * 2022-02-01, [Implement macro meta-variable expressions](rust-lang#93545) * 2022-02-25, [[1/2] Implement macro meta-variable expressions](rust-lang#94368) * 2022-03-11, [[2/2] Implement macro meta-variable expressions](rust-lang#94833) * 2022-03-12, [Fix remaining meta-variable expression TODOs](rust-lang#94884) * 2019-03-21, [[macro-metavar-expr] Fix generated tokens hygiene](rust-lang#95188) * 2022-04-07, [Kickstart the inner usage of macro_metavar_expr](rust-lang#95761) * 2022-04-07, [[macro_metavar_expr] Add tests to ensure the feature requirement](rust-lang#95764) ## Non-stabilized expressions rust-lang#83527 lists several concerns about some characteristics of `count`, `index` and `length` that effectively make their stabilization unfeasible. `$$` and `ignore`, however, are not part of any discussion and thus are suitable for stabilization. It is not in the scope of this PR to detail each concern or suggest any possible converging solution. Such thing should be restrained in this tracking issue. ## Tests This list is a subset of https://github.com/rust-lang/rust/tree/master/src/test/ui/macros/rfc-3086-metavar-expr * [Ensures that nested macros have correct behavior](https://github.com/rust-lang/rust/blob/master/src/test/ui/macros/rfc-3086-metavar-expr/dollar-dollar-has-correct-behavior.rs) * [Compares produced tokens to assert expected outputs](https://github.com/rust-lang/rust/blob/master/src/test/ui/macros/rfc-3086-metavar-expr/feature-gate-macro_metavar_expr.rs) * [Checks the declarations of the feature](https://github.com/rust-lang/rust/blob/master/src/test/ui/macros/rfc-3086-metavar-expr/required-feature.rs) * [Verifies all possible errors that can occur due to incorrect user input](https://github.com/rust-lang/rust/blob/master/src/test/ui/macros/rfc-3086-metavar-expr/syntax-errors.rs) ## Possible future work Once consensus is achieved, other nightly expressions can be stabilized. Thanks `@markbt` for creating the RFC and thanks to `@petrochenkov` and `@mark-i-m` for reviewing the implementations.
JohnTitor
added a commit
to JohnTitor/rust
that referenced
this pull request
Jun 9, 2022
…lett Stabilize `$$` in Rust 1.63.0 # Stabilization proposal This PR proposes the stabilization of a subset of `#![feature(macro_metavar_expr)]` or more specifically, the stabilization of dollar-dollar (`$$`). Tracking issue: rust-lang#83527 Version: 1.63 (2022-06-28 => beta, 2022-08-11 => stable). ## What is stabilized ```rust macro_rules! foo { () => { macro_rules! bar { ( $$( $$any:tt )* ) => { $$( $$any )* }; } }; } fn main() { foo!(); } ``` ## Motivation For more examples, see the [RFC](https://github.com/markbt/rfcs/blob/macro_metavar_expr/text/0000-macro-metavar-expr.md). Users must currently resort to a tricky and not so well-known hack to declare nested macros with repetitions. ```rust macro_rules! foo { ($dollar:tt) => { macro_rules! bar { ( $dollar ( $any:tt )* ) => { $dollar ( $any )* }; } }; } fn main() { foo!($); } ``` As seen above, such hack is fragile and makes work with declarative macros much more unpleasant. Dollar-dollar (`$$`), on the other hand, makes nested macros more intuitive. ## What isn't stabilized `count`, `ignore`, `index` and `length` are not being stabilized due to the lack of consensus. ## History * 2021-02-22, [RFC: Declarative macro metavariable expressions](rust-lang/rfcs#3086) * 2021-03-26, [Tracking Issue for RFC 3086: macro metavariable expressions](rust-lang#83527) * 2022-02-01, [Implement macro meta-variable expressions](rust-lang#93545) * 2022-02-25, [[1/2] Implement macro meta-variable expressions](rust-lang#94368) * 2022-03-11, [[2/2] Implement macro meta-variable expressions](rust-lang#94833) * 2022-03-12, [Fix remaining meta-variable expression TODOs](rust-lang#94884) * 2019-03-21, [[macro-metavar-expr] Fix generated tokens hygiene](rust-lang#95188) * 2022-04-07, [Kickstart the inner usage of macro_metavar_expr](rust-lang#95761) * 2022-04-07, [[macro_metavar_expr] Add tests to ensure the feature requirement](rust-lang#95764) ## Non-stabilized expressions rust-lang#83527 lists several concerns about some characteristics of `count`, `index` and `length` that effectively make their stabilization unfeasible. `$$` and `ignore`, however, are not part of any discussion and thus are suitable for stabilization. It is not in the scope of this PR to detail each concern or suggest any possible converging solution. Such thing should be restrained in this tracking issue. ## Tests This list is a subset of https://github.com/rust-lang/rust/tree/master/src/test/ui/macros/rfc-3086-metavar-expr * [Ensures that nested macros have correct behavior](https://github.com/rust-lang/rust/blob/master/src/test/ui/macros/rfc-3086-metavar-expr/dollar-dollar-has-correct-behavior.rs) * [Compares produced tokens to assert expected outputs](https://github.com/rust-lang/rust/blob/master/src/test/ui/macros/rfc-3086-metavar-expr/feature-gate-macro_metavar_expr.rs) * [Checks the declarations of the feature](https://github.com/rust-lang/rust/blob/master/src/test/ui/macros/rfc-3086-metavar-expr/required-feature.rs) * [Verifies all possible errors that can occur due to incorrect user input](https://github.com/rust-lang/rust/blob/master/src/test/ui/macros/rfc-3086-metavar-expr/syntax-errors.rs) ## Possible future work Once consensus is achieved, other nightly expressions can be stabilized. Thanks ``@markbt`` for creating the RFC and thanks to ``@petrochenkov`` and ``@mark-i-m`` for reviewing the implementations.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Only uses
Marker
on generated tokens -> #83527 (comment))I really don't know how to test this PR
r? @petrochenkov