diff --git a/compiler/rustc_expand/messages.ftl b/compiler/rustc_expand/messages.ftl index 7bc15e38f821b..fdd1a87cae809 100644 --- a/compiler/rustc_expand/messages.ftl +++ b/compiler/rustc_expand/messages.ftl @@ -42,9 +42,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/errors.rs b/compiler/rustc_expand/src/errors.rs index fa87e383d5157..21ce5e1d81e6e 100644 --- a/compiler/rustc_expand/src/errors.rs +++ b/compiler/rustc_expand/src/errors.rs @@ -456,10 +456,3 @@ pub struct ExpectedParenOrBrace<'a> { pub span: Span, pub token: Cow<'a, str>, } - -#[derive(Diagnostic)] -#[diag(expand_expr_2021_is_experimental)] -pub struct Expr2021IsExperimental { - #[primary_span] - pub span: Span, -} diff --git a/compiler/rustc_expand/src/mbe/quoted.rs b/compiler/rustc_expand/src/mbe/quoted.rs index 5508c0d0503c4..132cae0df4c4a 100644 --- a/compiler/rustc_expand/src/mbe/quoted.rs +++ b/compiler/rustc_expand/src/mbe/quoted.rs @@ -95,8 +95,13 @@ pub(super) fn parse( if kind == token::NonterminalKind::Expr2021 && !features.expr_fragment_specifier_2024 { - sess.dcx() - .emit_err(errors::Expr2021IsExperimental { span }); + rustc_session::parse::feature_err( + sess, + sym::expr_fragment_specifier_2024, + span, + "fragment specifier `expr_2021` is unstable", + ) + .emit(); } result.push(TokenTree::MetaVarDecl(span, ident, Some(kind))); continue; 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 fff1ea34d83e6..5a737b298214d 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: expr_2021 is experimental + ($e:expr_2021) => { //~ ERROR: fragment specifier `expr_2021` is unstable $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 078ff57a971f1..273a93877ce13 100644 --- a/tests/ui/macros/feature-gate-expr_fragment_specifier_2024.stderr +++ b/tests/ui/macros/feature-gate-expr_fragment_specifier_2024.stderr @@ -1,8 +1,13 @@ -error: expr_2021 is experimental +error[E0658]: fragment specifier `expr_2021` is unstable --> $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`.