From ba02e65691e2038d22e16fb54330fcbf6a5b583b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Le=C3=B3n=20Orell=20Valerian=20Liehr?= Date: Wed, 22 May 2024 01:10:38 +0200 Subject: [PATCH 1/6] Revert "Update compiler/rustc_parse/src/parser/nonterminal.rs" This reverts commit 3986ea0ea555ab6de8af46932da94c26aa1c28ee. --- compiler/rustc_parse/src/parser/nonterminal.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_parse/src/parser/nonterminal.rs b/compiler/rustc_parse/src/parser/nonterminal.rs index 619c4c63e5111..5d5ef8b3e3cbc 100644 --- a/compiler/rustc_parse/src/parser/nonterminal.rs +++ b/compiler/rustc_parse/src/parser/nonterminal.rs @@ -4,6 +4,7 @@ use rustc_ast::HasTokens; use rustc_ast_pretty::pprust; use rustc_data_structures::sync::Lrc; use rustc_errors::PResult; +use rustc_span::edition::Edition; use rustc_span::symbol::{kw, Ident}; use crate::errors::UnexpectedNonterminal; @@ -47,7 +48,7 @@ impl<'a> Parser<'a> { token.can_begin_expr() // This exception is here for backwards compatibility. && !token.is_keyword(kw::Let) - && (token.span.edition().at_least_rust_2024() || !token.is_keyword(kw::Const)) + && (token.span.edition() >= Edition::Edition2024 || !token.is_keyword(kw::Const)) } NonterminalKind::Ty => token.can_begin_type(), NonterminalKind::Ident => get_macro_ident(token).is_some(), From 56840d9416ccf16213f4c6ab8275d4512c6ab1fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Le=C3=B3n=20Orell=20Valerian=20Liehr?= Date: Wed, 22 May 2024 01:10:59 +0200 Subject: [PATCH 2/6] Revert "Apply code review suggestions" This reverts commit f364011955f8316f897cc0a2a930b8665d918177. --- compiler/rustc_ast/src/token.rs | 2 +- compiler/rustc_expand/messages.ftl | 3 + compiler/rustc_expand/src/mbe/quoted.rs | 69 +++++++------------ tests/ui/macros/expr_2021_old_edition.rs | 2 +- tests/ui/macros/expr_2021_old_edition.stderr | 3 +- ...ature-gate-expr_fragment_specifier_2024.rs | 2 +- ...e-gate-expr_fragment_specifier_2024.stderr | 7 +- 7 files changed, 31 insertions(+), 57 deletions(-) diff --git a/compiler/rustc_ast/src/token.rs b/compiler/rustc_ast/src/token.rs index 099a6096d0b5d..8e7397b37980f 100644 --- a/compiler/rustc_ast/src/token.rs +++ b/compiler/rustc_ast/src/token.rs @@ -912,7 +912,7 @@ impl NonterminalKind { }, sym::pat_param => NonterminalKind::PatParam { inferred: false }, sym::expr => NonterminalKind::Expr, - sym::expr_2021 if edition().at_least_rust_2021() => NonterminalKind::Expr2021, + sym::expr_2021 if edition() >= Edition::Edition2021 => NonterminalKind::Expr2021, sym::ty => NonterminalKind::Ty, sym::ident => NonterminalKind::Ident, sym::lifetime => NonterminalKind::Lifetime, diff --git a/compiler/rustc_expand/messages.ftl b/compiler/rustc_expand/messages.ftl index 530b37aadb1f5..942706b031050 100644 --- a/compiler/rustc_expand/messages.ftl +++ b/compiler/rustc_expand/messages.ftl @@ -47,6 +47,9 @@ expand_explain_doc_comment_inner = expand_explain_doc_comment_outer = outer doc comments expand to `#[doc = "..."]`, which is what this macro attempted to match +expand_expr_2021_is_experimental = + expr_2021 is experimental + expand_expr_repeat_no_syntax_vars = attempted to repeat an expression containing no syntax variables matched as repeating at this depth diff --git a/compiler/rustc_expand/src/mbe/quoted.rs b/compiler/rustc_expand/src/mbe/quoted.rs index d3ea48e2e2a8e..8d06dcf02b8e0 100644 --- a/compiler/rustc_expand/src/mbe/quoted.rs +++ b/compiler/rustc_expand/src/mbe/quoted.rs @@ -16,10 +16,6 @@ use rustc_span::Span; const VALID_FRAGMENT_NAMES_MSG: &str = "valid fragment specifiers are \ `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, \ `literal`, `path`, `meta`, `tt`, `item` and `vis`"; -const VALID_FRAGMENT_NAMES_MSG_2021: &str = "valid fragment specifiers are \ - `ident`, `block`, `stmt`, `expr`, `expr_2021`, `pat`, \ - `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, \ - `item` and `vis`"; /// Takes a `tokenstream::TokenStream` and returns a `Vec`. Specifically, this /// takes a generic `TokenStream`, such as is used in the rest of the compiler, and returns a @@ -67,59 +63,40 @@ pub(super) fn parse( Some(tokenstream::TokenTree::Token(token, _)) => match token.ident() { Some((fragment, _)) => { let span = token.span.with_lo(start_sp.lo()); - let edition = || { - // FIXME(#85708) - once we properly decode a foreign - // crate's `SyntaxContext::root`, then we can replace - // this with just `span.edition()`. A - // `SyntaxContext::root()` from the current crate will - // have the edition of the current crate, and a - // `SyntaxContext::root()` from a foreign crate will - // have the edition of that crate (which we manually - // retrieve via the `edition` parameter). - if !span.from_expansion() { - edition - } else { - span.edition() - } - }; + let kind = - token::NonterminalKind::from_symbol(fragment.name, edition) - .unwrap_or_else(|| { - let help = match fragment.name { - sym::expr_2021 => { - format!( - "fragment specifier `expr_2021` \ - requires Rust 2021 or later\n\ - {VALID_FRAGMENT_NAMES_MSG}" - ) - } - _ if edition().at_least_rust_2021() - && features - .expr_fragment_specifier_2024 => - { - VALID_FRAGMENT_NAMES_MSG_2021.into() - } - _ => VALID_FRAGMENT_NAMES_MSG.into(), - }; + token::NonterminalKind::from_symbol(fragment.name, || { + // FIXME(#85708) - once we properly decode a foreign + // crate's `SyntaxContext::root`, then we can replace + // this with just `span.edition()`. A + // `SyntaxContext::root()` from the current crate will + // have the edition of the current crate, and a + // `SyntaxContext::root()` from a foreign crate will + // have the edition of that crate (which we manually + // retrieve via the `edition` parameter). + if !span.from_expansion() { + edition + } else { + span.edition() + } + }) + .unwrap_or_else( + || { sess.dcx().emit_err( errors::InvalidFragmentSpecifier { span, fragment, - help, + help: VALID_FRAGMENT_NAMES_MSG.into(), }, ); token::NonterminalKind::Ident - }); + }, + ); if kind == token::NonterminalKind::Expr2021 && !features.expr_fragment_specifier_2024 { - rustc_session::parse::feature_err( - sess, - sym::expr_fragment_specifier_2024, - span, - "fragment specifier `expr_2021` is unstable", - ) - .emit(); + sess.dcx() + .emit_err(errors::Expr2021IsExperimental { span }); } result.push(TokenTree::MetaVarDecl(span, ident, Some(kind))); continue; diff --git a/tests/ui/macros/expr_2021_old_edition.rs b/tests/ui/macros/expr_2021_old_edition.rs index a771126610686..ab7999ab3731f 100644 --- a/tests/ui/macros/expr_2021_old_edition.rs +++ b/tests/ui/macros/expr_2021_old_edition.rs @@ -1,6 +1,6 @@ //@ compile-flags: --edition=2018 -// This test ensures that expr_2021 is not allowed on pre-2021 editions +// This test ensures that expr_2021 is not allowed on pre-2024 editions macro_rules! m { ($e:expr_2021) => { //~ ERROR: invalid fragment specifier `expr_2021` diff --git a/tests/ui/macros/expr_2021_old_edition.stderr b/tests/ui/macros/expr_2021_old_edition.stderr index bffa8a1ca1759..b5934fb3361b2 100644 --- a/tests/ui/macros/expr_2021_old_edition.stderr +++ b/tests/ui/macros/expr_2021_old_edition.stderr @@ -4,8 +4,7 @@ error: invalid fragment specifier `expr_2021` LL | ($e:expr_2021) => { | ^^^^^^^^^^^^ | - = help: fragment specifier `expr_2021` requires Rust 2021 or later - valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis` + = help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis` error: no rules expected the token `(` --> $DIR/expr_2021_old_edition.rs:12:8 diff --git a/tests/ui/macros/feature-gate-expr_fragment_specifier_2024.rs b/tests/ui/macros/feature-gate-expr_fragment_specifier_2024.rs index 5a737b298214d..fff1ea34d83e6 100644 --- a/tests/ui/macros/feature-gate-expr_fragment_specifier_2024.rs +++ b/tests/ui/macros/feature-gate-expr_fragment_specifier_2024.rs @@ -1,7 +1,7 @@ //@ compile-flags: --edition=2024 -Z unstable-options macro_rules! m { - ($e:expr_2021) => { //~ ERROR: fragment specifier `expr_2021` is unstable + ($e:expr_2021) => { //~ ERROR: expr_2021 is experimental $e }; } diff --git a/tests/ui/macros/feature-gate-expr_fragment_specifier_2024.stderr b/tests/ui/macros/feature-gate-expr_fragment_specifier_2024.stderr index 273a93877ce13..078ff57a971f1 100644 --- a/tests/ui/macros/feature-gate-expr_fragment_specifier_2024.stderr +++ b/tests/ui/macros/feature-gate-expr_fragment_specifier_2024.stderr @@ -1,13 +1,8 @@ -error[E0658]: fragment specifier `expr_2021` is unstable +error: expr_2021 is experimental --> $DIR/feature-gate-expr_fragment_specifier_2024.rs:4:6 | LL | ($e:expr_2021) => { | ^^^^^^^^^^^^ - | - = note: see issue #123742 for more information - = help: add `#![feature(expr_fragment_specifier_2024)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0658`. From 26d84dbdf09e7ef0075d9806320622de7b06c93d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Le=C3=B3n=20Orell=20Valerian=20Liehr?= Date: Wed, 22 May 2024 01:11:02 +0200 Subject: [PATCH 3/6] Revert "Macros: match const { ... } with expr nonterminal in edition 2024" This reverts commit a55d06323aef19040aba222b7ede790291e08468. --- .../rustc_parse/src/parser/nonterminal.rs | 9 +----- .../expr_2021_inline_const.edi2021.stderr | 32 ------------------- .../expr_2021_inline_const.edi2024.stderr | 17 ---------- tests/ui/macros/expr_2021_inline_const.rs | 23 ------------- 4 files changed, 1 insertion(+), 80 deletions(-) delete mode 100644 tests/ui/macros/expr_2021_inline_const.edi2021.stderr delete mode 100644 tests/ui/macros/expr_2021_inline_const.edi2024.stderr delete mode 100644 tests/ui/macros/expr_2021_inline_const.rs diff --git a/compiler/rustc_parse/src/parser/nonterminal.rs b/compiler/rustc_parse/src/parser/nonterminal.rs index 5d5ef8b3e3cbc..7afa3ac375af4 100644 --- a/compiler/rustc_parse/src/parser/nonterminal.rs +++ b/compiler/rustc_parse/src/parser/nonterminal.rs @@ -4,7 +4,6 @@ use rustc_ast::HasTokens; use rustc_ast_pretty::pprust; use rustc_data_structures::sync::Lrc; use rustc_errors::PResult; -use rustc_span::edition::Edition; use rustc_span::symbol::{kw, Ident}; use crate::errors::UnexpectedNonterminal; @@ -37,19 +36,13 @@ impl<'a> Parser<'a> { } match kind { - NonterminalKind::Expr2021 => { + NonterminalKind::Expr | NonterminalKind::Expr2021 => { token.can_begin_expr() // This exception is here for backwards compatibility. && !token.is_keyword(kw::Let) // This exception is here for backwards compatibility. && !token.is_keyword(kw::Const) } - NonterminalKind::Expr => { - token.can_begin_expr() - // This exception is here for backwards compatibility. - && !token.is_keyword(kw::Let) - && (token.span.edition() >= Edition::Edition2024 || !token.is_keyword(kw::Const)) - } NonterminalKind::Ty => token.can_begin_type(), NonterminalKind::Ident => get_macro_ident(token).is_some(), NonterminalKind::Literal => token.can_begin_literal_maybe_minus(), diff --git a/tests/ui/macros/expr_2021_inline_const.edi2021.stderr b/tests/ui/macros/expr_2021_inline_const.edi2021.stderr deleted file mode 100644 index 5e88096445473..0000000000000 --- a/tests/ui/macros/expr_2021_inline_const.edi2021.stderr +++ /dev/null @@ -1,32 +0,0 @@ -error: no rules expected the token `const` - --> $DIR/expr_2021_inline_const.rs:21:12 - | -LL | macro_rules! m2021 { - | ------------------ when calling this macro -... -LL | m2021!(const { 1 }); - | ^^^^^ no rules expected this token in macro call - | -note: while trying to match meta-variable `$e:expr_2021` - --> $DIR/expr_2021_inline_const.rs:10:6 - | -LL | ($e:expr_2021) => { - | ^^^^^^^^^^^^ - -error: no rules expected the token `const` - --> $DIR/expr_2021_inline_const.rs:22:12 - | -LL | macro_rules! m2024 { - | ------------------ when calling this macro -... -LL | m2024!(const { 1 }); - | ^^^^^ no rules expected this token in macro call - | -note: while trying to match meta-variable `$e:expr` - --> $DIR/expr_2021_inline_const.rs:16:6 - | -LL | ($e:expr) => { - | ^^^^^^^ - -error: aborting due to 2 previous errors - diff --git a/tests/ui/macros/expr_2021_inline_const.edi2024.stderr b/tests/ui/macros/expr_2021_inline_const.edi2024.stderr deleted file mode 100644 index 237ecb2cc192a..0000000000000 --- a/tests/ui/macros/expr_2021_inline_const.edi2024.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error: no rules expected the token `const` - --> $DIR/expr_2021_inline_const.rs:21:12 - | -LL | macro_rules! m2021 { - | ------------------ when calling this macro -... -LL | m2021!(const { 1 }); - | ^^^^^ no rules expected this token in macro call - | -note: while trying to match meta-variable `$e:expr_2021` - --> $DIR/expr_2021_inline_const.rs:10:6 - | -LL | ($e:expr_2021) => { - | ^^^^^^^^^^^^ - -error: aborting due to 1 previous error - diff --git a/tests/ui/macros/expr_2021_inline_const.rs b/tests/ui/macros/expr_2021_inline_const.rs deleted file mode 100644 index ebc5ea3642108..0000000000000 --- a/tests/ui/macros/expr_2021_inline_const.rs +++ /dev/null @@ -1,23 +0,0 @@ -//@ revisions: edi2021 edi2024 -//@[edi2024]compile-flags: --edition=2024 -Z unstable-options -//@[edi2021]compile-flags: --edition=2021 - -// This test ensures that the inline const match only on edition 2024 -#![feature(expr_fragment_specifier_2024)] -#![allow(incomplete_features)] - -macro_rules! m2021 { - ($e:expr_2021) => { - $e - }; -} - -macro_rules! m2024 { - ($e:expr) => { - $e - }; -} -fn main() { - m2021!(const { 1 }); //~ ERROR: no rules expected the token `const` - m2024!(const { 1 }); //[edi2021]~ ERROR: no rules expected the token `const` -} From 217861520f4cef7a6c8ecf771a428105d40a44d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Le=C3=B3n=20Orell=20Valerian=20Liehr?= Date: Wed, 22 May 2024 01:11:04 +0200 Subject: [PATCH 4/6] Revert "expr_2021 should be allowed on edition 2021 and later" This reverts commit 73303c3b454379772053957d88437277a121c173. --- compiler/rustc_ast/src/token.rs | 2 +- tests/ui/macros/expr_2021_old_edition.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_ast/src/token.rs b/compiler/rustc_ast/src/token.rs index 8e7397b37980f..50086574db193 100644 --- a/compiler/rustc_ast/src/token.rs +++ b/compiler/rustc_ast/src/token.rs @@ -912,7 +912,7 @@ impl NonterminalKind { }, sym::pat_param => NonterminalKind::PatParam { inferred: false }, sym::expr => NonterminalKind::Expr, - sym::expr_2021 if edition() >= Edition::Edition2021 => NonterminalKind::Expr2021, + sym::expr_2021 if edition() >= Edition::Edition2024 => NonterminalKind::Expr2021, sym::ty => NonterminalKind::Ty, sym::ident => NonterminalKind::Ident, sym::lifetime => NonterminalKind::Lifetime, diff --git a/tests/ui/macros/expr_2021_old_edition.rs b/tests/ui/macros/expr_2021_old_edition.rs index ab7999ab3731f..329c5cdca3355 100644 --- a/tests/ui/macros/expr_2021_old_edition.rs +++ b/tests/ui/macros/expr_2021_old_edition.rs @@ -1,4 +1,4 @@ -//@ compile-flags: --edition=2018 +//@ compile-flags: --edition=2021 // This test ensures that expr_2021 is not allowed on pre-2024 editions From e814d8b1bc0f2b1cb8c1e93e4d8df24d0d2ce944 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Le=C3=B3n=20Orell=20Valerian=20Liehr?= Date: Wed, 22 May 2024 01:11:06 +0200 Subject: [PATCH 5/6] Revert "Add test that expr_2021 only works on 2024 edition" This reverts commit 65da4adfcd12a062874524a37ebd4f522c04205f. --- tests/ui/macros/expr_2021_old_edition.rs | 13 ---------- tests/ui/macros/expr_2021_old_edition.stderr | 25 -------------------- 2 files changed, 38 deletions(-) delete mode 100644 tests/ui/macros/expr_2021_old_edition.rs delete mode 100644 tests/ui/macros/expr_2021_old_edition.stderr diff --git a/tests/ui/macros/expr_2021_old_edition.rs b/tests/ui/macros/expr_2021_old_edition.rs deleted file mode 100644 index 329c5cdca3355..0000000000000 --- a/tests/ui/macros/expr_2021_old_edition.rs +++ /dev/null @@ -1,13 +0,0 @@ -//@ compile-flags: --edition=2021 - -// This test ensures that expr_2021 is not allowed on pre-2024 editions - -macro_rules! m { - ($e:expr_2021) => { //~ ERROR: invalid fragment specifier `expr_2021` - $e - }; -} - -fn main() { - m!(()); //~ ERROR: no rules expected the token `(` -} diff --git a/tests/ui/macros/expr_2021_old_edition.stderr b/tests/ui/macros/expr_2021_old_edition.stderr deleted file mode 100644 index b5934fb3361b2..0000000000000 --- a/tests/ui/macros/expr_2021_old_edition.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error: invalid fragment specifier `expr_2021` - --> $DIR/expr_2021_old_edition.rs:6:6 - | -LL | ($e:expr_2021) => { - | ^^^^^^^^^^^^ - | - = help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis` - -error: no rules expected the token `(` - --> $DIR/expr_2021_old_edition.rs:12:8 - | -LL | macro_rules! m { - | -------------- when calling this macro -... -LL | m!(()); - | ^ no rules expected this token in macro call - | -note: while trying to match meta-variable `$e:ident` - --> $DIR/expr_2021_old_edition.rs:6:6 - | -LL | ($e:expr_2021) => { - | ^^^^^^^^^^^^ - -error: aborting due to 2 previous errors - From e8d39b6779e25e513b4eb1b5758dd172a0c172c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Le=C3=B3n=20Orell=20Valerian=20Liehr?= Date: Wed, 22 May 2024 01:11:23 +0200 Subject: [PATCH 6/6] Revert "Add expr_2021 nonterminal and feature flag" This reverts commit ef6478ba5fde1a1ed6db27fc7f558bc26e38d781. --- compiler/rustc_ast/src/token.rs | 4 ---- compiler/rustc_expand/messages.ftl | 3 --- compiler/rustc_expand/src/mbe/macro_rules.rs | 2 +- compiler/rustc_expand/src/mbe/quoted.rs | 6 ------ compiler/rustc_feature/src/unstable.rs | 2 -- compiler/rustc_parse/src/parser/nonterminal.rs | 6 ++---- compiler/rustc_span/src/symbol.rs | 2 -- .../feature-gate-expr_fragment_specifier_2024.rs | 11 ----------- .../feature-gate-expr_fragment_specifier_2024.stderr | 8 -------- 9 files changed, 3 insertions(+), 41 deletions(-) delete mode 100644 tests/ui/macros/feature-gate-expr_fragment_specifier_2024.rs delete mode 100644 tests/ui/macros/feature-gate-expr_fragment_specifier_2024.stderr diff --git a/compiler/rustc_ast/src/token.rs b/compiler/rustc_ast/src/token.rs index 50086574db193..d00352ea2e130 100644 --- a/compiler/rustc_ast/src/token.rs +++ b/compiler/rustc_ast/src/token.rs @@ -881,8 +881,6 @@ pub enum NonterminalKind { }, PatWithOr, Expr, - /// Matches an expression using the rules from edition 2021 and earlier. - Expr2021, Ty, Ident, Lifetime, @@ -912,7 +910,6 @@ impl NonterminalKind { }, sym::pat_param => NonterminalKind::PatParam { inferred: false }, sym::expr => NonterminalKind::Expr, - sym::expr_2021 if edition() >= Edition::Edition2024 => NonterminalKind::Expr2021, sym::ty => NonterminalKind::Ty, sym::ident => NonterminalKind::Ident, sym::lifetime => NonterminalKind::Lifetime, @@ -932,7 +929,6 @@ impl NonterminalKind { NonterminalKind::PatParam { inferred: false } => sym::pat_param, NonterminalKind::PatParam { inferred: true } | NonterminalKind::PatWithOr => sym::pat, NonterminalKind::Expr => sym::expr, - NonterminalKind::Expr2021 => sym::expr_2021, NonterminalKind::Ty => sym::ty, NonterminalKind::Ident => sym::ident, NonterminalKind::Lifetime => sym::lifetime, diff --git a/compiler/rustc_expand/messages.ftl b/compiler/rustc_expand/messages.ftl index 942706b031050..530b37aadb1f5 100644 --- a/compiler/rustc_expand/messages.ftl +++ b/compiler/rustc_expand/messages.ftl @@ -47,9 +47,6 @@ expand_explain_doc_comment_inner = expand_explain_doc_comment_outer = outer doc comments expand to `#[doc = "..."]`, which is what this macro attempted to match -expand_expr_2021_is_experimental = - expr_2021 is experimental - expand_expr_repeat_no_syntax_vars = attempted to repeat an expression containing no syntax variables matched as repeating at this depth diff --git a/compiler/rustc_expand/src/mbe/macro_rules.rs b/compiler/rustc_expand/src/mbe/macro_rules.rs index 8f18055f83817..6ce1de5ad39fc 100644 --- a/compiler/rustc_expand/src/mbe/macro_rules.rs +++ b/compiler/rustc_expand/src/mbe/macro_rules.rs @@ -1293,7 +1293,7 @@ fn is_in_follow(tok: &mbe::TokenTree, kind: NonterminalKind) -> IsInFollow { // maintain IsInFollow::Yes } - NonterminalKind::Stmt | NonterminalKind::Expr | NonterminalKind::Expr2021 => { + NonterminalKind::Stmt | NonterminalKind::Expr => { const TOKENS: &[&str] = &["`=>`", "`,`", "`;`"]; match tok { TokenTree::Token(token) => match token.kind { diff --git a/compiler/rustc_expand/src/mbe/quoted.rs b/compiler/rustc_expand/src/mbe/quoted.rs index 8d06dcf02b8e0..2e5596f51c35d 100644 --- a/compiler/rustc_expand/src/mbe/quoted.rs +++ b/compiler/rustc_expand/src/mbe/quoted.rs @@ -92,12 +92,6 @@ pub(super) fn parse( token::NonterminalKind::Ident }, ); - if kind == token::NonterminalKind::Expr2021 - && !features.expr_fragment_specifier_2024 - { - sess.dcx() - .emit_err(errors::Expr2021IsExperimental { span }); - } result.push(TokenTree::MetaVarDecl(span, ident, Some(kind))); continue; } diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index dc4807bab2d3d..b374c0df42a56 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -458,8 +458,6 @@ declare_features! ( (unstable, exhaustive_patterns, "1.13.0", Some(51085)), /// Allows explicit tail calls via `become` expression. (incomplete, explicit_tail_calls, "1.72.0", Some(112788)), - /// Uses 2024 rules for matching `expr` fragments in macros. Also enables `expr_2021` fragment. - (incomplete, expr_fragment_specifier_2024, "CURRENT_RUSTC_VERSION", Some(123742)), /// Allows using `efiapi`, `sysv64` and `win64` as calling convention /// for functions with varargs. (unstable, extended_varargs_abi_support, "1.65.0", Some(100189)), diff --git a/compiler/rustc_parse/src/parser/nonterminal.rs b/compiler/rustc_parse/src/parser/nonterminal.rs index 7afa3ac375af4..a6f0ab78b5c29 100644 --- a/compiler/rustc_parse/src/parser/nonterminal.rs +++ b/compiler/rustc_parse/src/parser/nonterminal.rs @@ -36,7 +36,7 @@ impl<'a> Parser<'a> { } match kind { - NonterminalKind::Expr | NonterminalKind::Expr2021 => { + NonterminalKind::Expr => { token.can_begin_expr() // This exception is here for backwards compatibility. && !token.is_keyword(kw::Let) @@ -143,9 +143,7 @@ impl<'a> Parser<'a> { })?) } - NonterminalKind::Expr | NonterminalKind::Expr2021 => { - NtExpr(self.parse_expr_force_collect()?) - } + NonterminalKind::Expr => NtExpr(self.parse_expr_force_collect()?), NonterminalKind::Literal => { // The `:literal` matcher does not support attributes NtLiteral(self.collect_tokens_no_attrs(|this| this.parse_literal_maybe_minus())?) diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index ace4dff46aa0a..85ed3865b9fde 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -782,8 +782,6 @@ symbols! { explicit_tail_calls, export_name, expr, - expr_2021, - expr_fragment_specifier_2024, extended_key_value_attributes, extended_varargs_abi_support, extern_absolute_paths, diff --git a/tests/ui/macros/feature-gate-expr_fragment_specifier_2024.rs b/tests/ui/macros/feature-gate-expr_fragment_specifier_2024.rs deleted file mode 100644 index fff1ea34d83e6..0000000000000 --- a/tests/ui/macros/feature-gate-expr_fragment_specifier_2024.rs +++ /dev/null @@ -1,11 +0,0 @@ -//@ compile-flags: --edition=2024 -Z unstable-options - -macro_rules! m { - ($e:expr_2021) => { //~ ERROR: expr_2021 is experimental - $e - }; -} - -fn main() { - m!(()); -} diff --git a/tests/ui/macros/feature-gate-expr_fragment_specifier_2024.stderr b/tests/ui/macros/feature-gate-expr_fragment_specifier_2024.stderr deleted file mode 100644 index 078ff57a971f1..0000000000000 --- a/tests/ui/macros/feature-gate-expr_fragment_specifier_2024.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: expr_2021 is experimental - --> $DIR/feature-gate-expr_fragment_specifier_2024.rs:4:6 - | -LL | ($e:expr_2021) => { - | ^^^^^^^^^^^^ - -error: aborting due to 1 previous error -