From e6e5bc728900a693de66ebf36788212777947bae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Tue, 19 Jul 2022 13:30:48 +0200 Subject: [PATCH] Rollup merge of #99435 - CAD97:revert-dollar-dollar-crate, r=Mark-Simulacrum Revert "Stabilize $$ in Rust 1.63.0" This mechanically reverts commit 9edaa76adce4de737db54194eb13d6c298827b37, the one commit from #95860. https://github.com/rust-lang/rust/issues/99035; the behavior of `$$crate` is potentially unexpected and not ready to be stabilized. https://github.com/rust-lang/rust/pull/99193 attempts to forbid `$$crate` without also destabilizing `$$` more generally. `@rustbot` modify labels +T-compiler +T-lang +P-medium +beta-nominated +relnotes (applying the labels I think are accurate from the issue and alternative partial revert) cc `@Mark-Simulacrum` --- compiler/rustc_expand/src/mbe/quoted.rs | 2 + .../rfc-3086-metavar-expr/allowed-features.rs | 12 ----- ...quired-features.rs => required-feature.rs} | 12 +++++ ...eatures.stderr => required-feature.stderr} | 50 ++++++++++++++++--- 4 files changed, 57 insertions(+), 19 deletions(-) delete mode 100644 src/test/ui/macros/rfc-3086-metavar-expr/allowed-features.rs rename src/test/ui/macros/rfc-3086-metavar-expr/{required-features.rs => required-feature.rs} (65%) rename src/test/ui/macros/rfc-3086-metavar-expr/{required-features.stderr => required-feature.stderr} (52%) diff --git a/compiler/rustc_expand/src/mbe/quoted.rs b/compiler/rustc_expand/src/mbe/quoted.rs index d4b8563a03666..707cb73f097f8 100644 --- a/compiler/rustc_expand/src/mbe/quoted.rs +++ b/compiler/rustc_expand/src/mbe/quoted.rs @@ -234,6 +234,8 @@ fn parse_tree( sess, &Token { kind: token::Dollar, span }, ); + } else { + maybe_emit_macro_metavar_expr_feature(features, sess, span); } TokenTree::token(token::Dollar, span) } diff --git a/src/test/ui/macros/rfc-3086-metavar-expr/allowed-features.rs b/src/test/ui/macros/rfc-3086-metavar-expr/allowed-features.rs deleted file mode 100644 index c248c46f52cd3..0000000000000 --- a/src/test/ui/macros/rfc-3086-metavar-expr/allowed-features.rs +++ /dev/null @@ -1,12 +0,0 @@ -// check-pass - -macro_rules! dollar_dollar { - () => { - macro_rules! bar { - ( $$( $$any:tt )* ) => { $$( $$any )* }; - } - }; -} - -fn main() { -} diff --git a/src/test/ui/macros/rfc-3086-metavar-expr/required-features.rs b/src/test/ui/macros/rfc-3086-metavar-expr/required-feature.rs similarity index 65% rename from src/test/ui/macros/rfc-3086-metavar-expr/required-features.rs rename to src/test/ui/macros/rfc-3086-metavar-expr/required-feature.rs index cce3e578aeafe..b4fef11f1e29a 100644 --- a/src/test/ui/macros/rfc-3086-metavar-expr/required-features.rs +++ b/src/test/ui/macros/rfc-3086-metavar-expr/required-feature.rs @@ -5,6 +5,18 @@ macro_rules! count { }; } +macro_rules! dollar_dollar { + () => { + macro_rules! bar { + ( $$( $$any:tt )* ) => { $$( $$any )* }; + //~^ ERROR meta-variable expressions are unstable + //~| ERROR meta-variable expressions are unstable + //~| ERROR meta-variable expressions are unstable + //~| ERROR meta-variable expressions are unstable + } + }; +} + macro_rules! index { ( $( $e:stmt ),* ) => { $( ${ignore(e)} ${index()} )* diff --git a/src/test/ui/macros/rfc-3086-metavar-expr/required-features.stderr b/src/test/ui/macros/rfc-3086-metavar-expr/required-feature.stderr similarity index 52% rename from src/test/ui/macros/rfc-3086-metavar-expr/required-features.stderr rename to src/test/ui/macros/rfc-3086-metavar-expr/required-feature.stderr index 5efd3b10442d1..ecf598b104d05 100644 --- a/src/test/ui/macros/rfc-3086-metavar-expr/required-features.stderr +++ b/src/test/ui/macros/rfc-3086-metavar-expr/required-feature.stderr @@ -1,5 +1,5 @@ error[E0658]: meta-variable expressions are unstable - --> $DIR/required-features.rs:3:10 + --> $DIR/required-feature.rs:3:10 | LL | ${ count(e) } | ^^^^^^^^^^^^ @@ -8,7 +8,43 @@ LL | ${ count(e) } = help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable error[E0658]: meta-variable expressions are unstable - --> $DIR/required-features.rs:10:13 + --> $DIR/required-feature.rs:11:16 + | +LL | ( $$( $$any:tt )* ) => { $$( $$any )* }; + | ^ + | + = note: see issue #83527 for more information + = help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable + +error[E0658]: meta-variable expressions are unstable + --> $DIR/required-feature.rs:11:20 + | +LL | ( $$( $$any:tt )* ) => { $$( $$any )* }; + | ^ + | + = note: see issue #83527 for more information + = help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable + +error[E0658]: meta-variable expressions are unstable + --> $DIR/required-feature.rs:11:39 + | +LL | ( $$( $$any:tt )* ) => { $$( $$any )* }; + | ^ + | + = note: see issue #83527 for more information + = help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable + +error[E0658]: meta-variable expressions are unstable + --> $DIR/required-feature.rs:11:43 + | +LL | ( $$( $$any:tt )* ) => { $$( $$any )* }; + | ^ + | + = note: see issue #83527 for more information + = help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable + +error[E0658]: meta-variable expressions are unstable + --> $DIR/required-feature.rs:22:13 | LL | $( ${ignore(e)} ${index()} )* | ^^^^^^^^^^^ @@ -17,7 +53,7 @@ LL | $( ${ignore(e)} ${index()} )* = help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable error[E0658]: meta-variable expressions are unstable - --> $DIR/required-features.rs:10:26 + --> $DIR/required-feature.rs:22:26 | LL | $( ${ignore(e)} ${index()} )* | ^^^^^^^^^ @@ -26,7 +62,7 @@ LL | $( ${ignore(e)} ${index()} )* = help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable error[E0658]: meta-variable expressions are unstable - --> $DIR/required-features.rs:18:19 + --> $DIR/required-feature.rs:30:19 | LL | 0 $( + 1 ${ignore(i)} )* | ^^^^^^^^^^^ @@ -35,7 +71,7 @@ LL | 0 $( + 1 ${ignore(i)} )* = help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable error[E0658]: meta-variable expressions are unstable - --> $DIR/required-features.rs:25:13 + --> $DIR/required-feature.rs:37:13 | LL | $( ${ignore(e)} ${length()} )* | ^^^^^^^^^^^ @@ -44,7 +80,7 @@ LL | $( ${ignore(e)} ${length()} )* = help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable error[E0658]: meta-variable expressions are unstable - --> $DIR/required-features.rs:25:26 + --> $DIR/required-feature.rs:37:26 | LL | $( ${ignore(e)} ${length()} )* | ^^^^^^^^^^ @@ -52,6 +88,6 @@ LL | $( ${ignore(e)} ${length()} )* = note: see issue #83527 for more information = help: add `#![feature(macro_metavar_expr)]` to the crate attributes to enable -error: aborting due to 6 previous errors +error: aborting due to 10 previous errors For more information about this error, try `rustc --explain E0658`.