From ebc4acee91dc9871d1c90f0d7a38aff0580dd18a Mon Sep 17 00:00:00 2001 From: mark Date: Mon, 22 Mar 2021 13:53:16 -0500 Subject: [PATCH] stabilize :pat2015, leave :pat2021 gated --- compiler/rustc_expand/src/mbe/quoted.rs | 23 ++++++++----------- compiler/rustc_feature/src/active.rs | 2 +- .../feature-gate-edition_macro_pats.rs | 4 ++-- .../feature-gate-edition_macro_pats.stderr | 13 ++--------- 4 files changed, 15 insertions(+), 27 deletions(-) diff --git a/compiler/rustc_expand/src/mbe/quoted.rs b/compiler/rustc_expand/src/mbe/quoted.rs index e205cb65d0229..c3e7448b63090 100644 --- a/compiler/rustc_expand/src/mbe/quoted.rs +++ b/compiler/rustc_expand/src/mbe/quoted.rs @@ -62,19 +62,16 @@ pub(super) fn parse( Some((frag, _)) => { let span = token.span.with_lo(start_sp.lo()); - match frag.name { - sym::pat2015 | sym::pat2021 => { - if !features.edition_macro_pats { - feature_err( - sess, - sym::edition_macro_pats, - frag.span, - "`pat2015` and `pat2021` are unstable.", - ) - .emit(); - } - } - _ => {} + if matches!(frag.name, sym::pat2021) + && !features.edition_macro_pats + { + feature_err( + sess, + sym::edition_macro_pats, + frag.span, + "`pat2021` is unstable.", + ) + .emit(); } let kind = diff --git a/compiler/rustc_feature/src/active.rs b/compiler/rustc_feature/src/active.rs index 1a91eb600a91b..774f21b2dd885 100644 --- a/compiler/rustc_feature/src/active.rs +++ b/compiler/rustc_feature/src/active.rs @@ -609,7 +609,7 @@ declare_features! ( /// Allows arbitrary expressions in key-value attributes at parse time. (active, extended_key_value_attributes, "1.50.0", Some(78835), None), - /// `:pat2015` and `:pat2021` macro matchers. + /// `:pat2021` macro matcher. (active, edition_macro_pats, "1.51.0", Some(54883), None), /// Allows const generics to have default values (e.g. `struct Foo(...);`). diff --git a/src/test/ui/feature-gates/feature-gate-edition_macro_pats.rs b/src/test/ui/feature-gates/feature-gate-edition_macro_pats.rs index 430a9437cee34..e9f813f83ae98 100644 --- a/src/test/ui/feature-gates/feature-gate-edition_macro_pats.rs +++ b/src/test/ui/feature-gates/feature-gate-edition_macro_pats.rs @@ -1,8 +1,8 @@ // Feature gate test for `edition_macro_pats` feature. macro_rules! foo { - ($x:pat2015) => {}; //~ERROR `pat2015` and `pat2021` are unstable - ($x:pat2021) => {}; //~ERROR `pat2015` and `pat2021` are unstable + ($x:pat2015) => {}; // ok + ($x:pat2021) => {}; //~ERROR `pat2021` is unstable } fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-edition_macro_pats.stderr b/src/test/ui/feature-gates/feature-gate-edition_macro_pats.stderr index d25bcaf929bcd..dc1f52d87a820 100644 --- a/src/test/ui/feature-gates/feature-gate-edition_macro_pats.stderr +++ b/src/test/ui/feature-gates/feature-gate-edition_macro_pats.stderr @@ -1,13 +1,4 @@ -error[E0658]: `pat2015` and `pat2021` are unstable. - --> $DIR/feature-gate-edition_macro_pats.rs:4:9 - | -LL | ($x:pat2015) => {}; - | ^^^^^^^ - | - = note: see issue #54883 for more information - = help: add `#![feature(edition_macro_pats)]` to the crate attributes to enable - -error[E0658]: `pat2015` and `pat2021` are unstable. +error[E0658]: `pat2021` is unstable. --> $DIR/feature-gate-edition_macro_pats.rs:5:9 | LL | ($x:pat2021) => {}; @@ -16,6 +7,6 @@ LL | ($x:pat2021) => {}; = note: see issue #54883 for more information = help: add `#![feature(edition_macro_pats)]` to the crate attributes to enable -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0658`.