Skip to content

Commit

Permalink
use feature_err to report unstable expr_2021
Browse files Browse the repository at this point in the history
  • Loading branch information
eholk committed May 1, 2024
1 parent 0d43437 commit 50a46b9
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
3 changes: 0 additions & 3 deletions compiler/rustc_expand/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 0 additions & 7 deletions compiler/rustc_expand/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
9 changes: 7 additions & 2 deletions compiler/rustc_expand/src/mbe/quoted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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
};
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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 <https://github.com/rust-lang/rust/issues/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`.

0 comments on commit 50a46b9

Please sign in to comment.