-
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
Tracking Issue for updating expr
macro fragment specifier for Rust 2024
#123742
Comments
Do we also need |
It depends on what changes to the grammar have occured. |
Can someone please write down what changes are being done for this? |
I haven't heard a clear answer, but it sounds like maybe supporting |
Based on #86730, it looks like we also need to update |
We might need to update |
I guess the other potential change for As I understand the RFC and #86730, we want to update This seems weird to me. Do we have I think instead it'd make more sense to add a |
Update `expr` matcher for Edition 2024 and add `expr_2021` nonterminal This commit adds a new nonterminal `expr_2021` in macro patterns, and `expr_fragment_specifier_2024` feature flag. This change also updates `expr` so that on Edition 2024 it will also match `const { ... }` blocks, while `expr_2021` preserves the current behavior of `expr`, matching expressions without `const` blocks. Joint work with `@vincenzopalazzo.` Issue rust-lang#123742
See also #126749 about whether or not |
@compiler-errors pointed out that |
…xpr2024, r=eholk migration lint for `expr2024` for the edition 2024 This is adding a migration lint for the current (in the 2021 edition and previous) to move expr to expr_2021 from expr Issue rust-lang#123742 I created also a repository to test out the migration https://github.com/vincenzopalazzo/expr2024-cargo-fix-migration Co-Developed-by: `@eholk`
Make edition dependent `:expr` macro fragment act like the edition-dependent `:pat` fragment does Parse the `:expr` fragment as `:expr_2021` in editions <=2021, and as `:expr` in edition 2024. This is similar to how we parse `:pat` as `:pat_param` in edition <=2018 and `:pat_with_or` in >=2021, and means we can get rid of a span dependency from `nonterminal_may_begin_with`. Specifically, this fixes a theoretical regression since the `expr_2021` macro fragment previously would allow `const {}` if the *caller* is edition 2024. This is inconsistent with the way that the `pat` macro fragment was upgraded, and also leads to surprising behavior when a macro *caller* crate upgrades to edtion 2024, since they may have parsing changes that they never asked for (with no way of opting out of it). This PR also allows using `expr_2021` in all editions. Why was this was disallowed in the first place? It's purely additive, and also it's still feature gated? r? `@fmease` `@eholk` cc `@vincenzopalazzo` cc rust-lang#123865 Tracking: - rust-lang#123742
Make edition dependent `:expr` macro fragment act like the edition-dependent `:pat` fragment does Parse the `:expr` fragment as `:expr_2021` in editions <=2021, and as `:expr` in edition 2024. This is similar to how we parse `:pat` as `:pat_param` in edition <=2018 and `:pat_with_or` in >=2021, and means we can get rid of a span dependency from `nonterminal_may_begin_with`. Specifically, this fixes a theoretical regression since the `expr_2021` macro fragment previously would allow `const {}` if the *caller* is edition 2024. This is inconsistent with the way that the `pat` macro fragment was upgraded, and also leads to surprising behavior when a macro *caller* crate upgrades to edtion 2024, since they may have parsing changes that they never asked for (with no way of opting out of it). This PR also allows using `expr_2021` in all editions. Why was this was disallowed in the first place? It's purely additive, and also it's still feature gated? r? ``@fmease`` ``@eholk`` cc ``@vincenzopalazzo`` cc rust-lang#123865 Tracking: - rust-lang#123742
Make edition dependent `:expr` macro fragment act like the edition-dependent `:pat` fragment does Parse the `:expr` fragment as `:expr_2021` in editions <=2021, and as `:expr` in edition 2024. This is similar to how we parse `:pat` as `:pat_param` in edition <=2018 and `:pat_with_or` in >=2021, and means we can get rid of a span dependency from `nonterminal_may_begin_with`. Specifically, this fixes a theoretical regression since the `expr_2021` macro fragment previously would allow `const {}` if the *caller* is edition 2024. This is inconsistent with the way that the `pat` macro fragment was upgraded, and also leads to surprising behavior when a macro *caller* crate upgrades to edtion 2024, since they may have parsing changes that they never asked for (with no way of opting out of it). This PR also allows using `expr_2021` in all editions. Why was this was disallowed in the first place? It's purely additive, and also it's still feature gated? r? ```@fmease``` ```@eholk``` cc ```@vincenzopalazzo``` cc rust-lang#123865 Tracking: - rust-lang#123742
Rollup merge of rust-lang#126700 - compiler-errors:fragment, r=fmease Make edition dependent `:expr` macro fragment act like the edition-dependent `:pat` fragment does Parse the `:expr` fragment as `:expr_2021` in editions <=2021, and as `:expr` in edition 2024. This is similar to how we parse `:pat` as `:pat_param` in edition <=2018 and `:pat_with_or` in >=2021, and means we can get rid of a span dependency from `nonterminal_may_begin_with`. Specifically, this fixes a theoretical regression since the `expr_2021` macro fragment previously would allow `const {}` if the *caller* is edition 2024. This is inconsistent with the way that the `pat` macro fragment was upgraded, and also leads to surprising behavior when a macro *caller* crate upgrades to edtion 2024, since they may have parsing changes that they never asked for (with no way of opting out of it). This PR also allows using `expr_2021` in all editions. Why was this was disallowed in the first place? It's purely additive, and also it's still feature gated? r? ```@fmease``` ```@eholk``` cc ```@vincenzopalazzo``` cc rust-lang#123865 Tracking: - rust-lang#123742
To confirm, the current understanding (now reflected in the issue description) is that the This is because this is currently an error on stable Rust: macro_rules! item {
($x:item) => {};
($(x:tt)*) => {};
}
fn main() {
item!(safe fn foo() {});
} ...and because this is not an error on stable Rust: macro_rules! item {
($x:item) => { 0u8 };
($(x:tt)*) => { 0u16 };
}
fn main() {
let _: u8 = item!(unsafe extern {});
} |
…pression_tok, r=eholk,compiler-errors [RFC] mbe: consider the `_` in 2024 an expression This commit is adding the possibility to parse the `_` as an expression inside the esition 2024. Link: https://rust-lang.zulipchat.com/#narrow/stream/404510-wg-macros/topic/supporting.20.60_.60.20expressions Issue rust-lang#123742 r? `@eholk`
Rollup merge of rust-lang#126697 - vincenzopalazzo:macros/find_the_expression_tok, r=eholk,compiler-errors [RFC] mbe: consider the `_` in 2024 an expression This commit is adding the possibility to parse the `_` as an expression inside the esition 2024. Link: https://rust-lang.zulipchat.com/#narrow/stream/404510-wg-macros/topic/supporting.20.60_.60.20expressions Issue rust-lang#123742 r? `@eholk`
@rustbot labels +I-lang-nominated Should we name this new specifier |
@rustbot labels -I-lang-nominated We discussed in the call today. We'll name this And we'll want to get that new specifier stabilized soon, ahead of the edition. |
…acros-between-edition, r=compiler-errors test: cross-edition metavar fragment specifiers There's a subtle interaction between macros with metavar expressions and the edition-dependent fragment matching behavior. This test illustrates the current behavior when using macro-generating-macros across crate boundaries with different editions. See the original suggestion rust-lang#123865 (comment) Tracking: - rust-lang#123742
…ros-between-edition, r=compiler-errors test: cross-edition metavar fragment specifiers There's a subtle interaction between macros with metavar expressions and the edition-dependent fragment matching behavior. This test illustrates the current behavior when using macro-generating-macros across crate boundaries with different editions. See the original suggestion rust-lang#123865 (comment) Tracking: - rust-lang#123742
…acros-between-edition, r=compiler-errors test: cross-edition metavar fragment specifiers There's a subtle interaction between macros with metavar expressions and the edition-dependent fragment matching behavior. This test illustrates the current behavior when using macro-generating-macros across crate boundaries with different editions. See the original suggestion rust-lang#123865 (comment) Tracking: - rust-lang#123742
Rollup merge of rust-lang#129755 - vincenzopalazzo:macros/recursive-macros-between-edition, r=compiler-errors test: cross-edition metavar fragment specifiers There's a subtle interaction between macros with metavar expressions and the edition-dependent fragment matching behavior. This test illustrates the current behavior when using macro-generating-macros across crate boundaries with different editions. See the original suggestion rust-lang#123865 (comment) Tracking: - rust-lang#123742
…r-errors Stabilize expr_2021 fragment specifier in all editions This is part of the `expr`/`expr_2021` fragment specifier for Edition 2024 (rust-lang#123742). The RFC says we can support expr_2021 in as many editions as is practical, and there's nothing particularly hard about supporting it all the way back to 2015. In editions 2021 and earlier, `expr` and `expr_2021` are synonyms. Their behavior diverges starting in Edition 2024. This is checked by the `expr_2021_inline_const.rs` test. cc `@vincenzopalazzo` `@rust-lang/wg-macros` `@traviscross`
…r-errors,traviscross Stabilize expr_2021 fragment specifier in all editions This is part of the `expr`/`expr_2021` fragment specifier for Edition 2024 (rust-lang#123742). The RFC says we can support expr_2021 in as many editions as is practical, and there's nothing particularly hard about supporting it all the way back to 2015. In editions 2021 and earlier, `expr` and `expr_2021` are synonyms. Their behavior diverges starting in Edition 2024. This is checked by the `expr_2021_inline_const.rs` test. cc `@vincenzopalazzo` `@rust-lang/wg-macros` `@traviscross`
@rustbot labels +S-tracking-ready-for-edition We reviewed this item in the edition call, and we confirmed this is now ready for Rust 2024. Thanks to @eholk and @vincenzopalazzo for pushing forward on this important work. |
Thank @traviscross manage and coordinate the work👌🏼 |
- 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
This is a tracking issue for updating the
expr
fragment specifier for Rust 2024 according to the policy described in RFC 3531:The feature gate for the issue is
#![feature(expr_fragment_specifier_2024)]
.About tracking issues
Tracking issues are used to record the overall progress of implementation. They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions. A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature. Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
Steps
expr
matcher for Edition 2024 and addexpr_2021
nonterminal #123865expr
to match_
._
in 2024 an expression #126697expr2024
for the edition 2024 #125627expr_2021
fragment specifier.:expr
macro fragment act like the edition-dependent:pat
fragment does #126700expr_2021
) in all editions.expr_2021
macro fragment specifier reference#1580expr
macro fragment specifier reference#1639Unresolved Questions
expr_2021
, or should we just call it that per the RFC?expr_2021
, see Tracking Issue for updatingexpr
macro fragment specifier for Rust 2024 #123742 (comment).Related
expr202x
macro pattern #84364expr
matcher for Edition 2024 and addexpr_2021
nonterminal #123865:expr
macro fragment act like the edition-dependent:pat
fragment does #126700_
in 2024 an expression #126697:expr
macro fragment act like the edition-dependent:pat
fragment does #126700cc @rust-lang/wg-macros @eholk @vincenzopalazzo
The text was updated successfully, but these errors were encountered: