about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--compiler/rustc_ast/src/token.rs14
-rw-r--r--compiler/rustc_expand/src/mbe/macro_rules.rs8
-rw-r--r--compiler/rustc_lint/src/context.rs2
-rw-r--r--compiler/rustc_parse/src/parser/nonterminal.rs10
-rw-r--r--compiler/rustc_span/src/symbol.rs2
-rw-r--r--src/test/ui/feature-gates/feature-gate-edition_macro_pats.rs2
-rw-r--r--src/test/ui/macros/edition-macro-pats.rs2
-rw-r--r--src/test/ui/macros/macro-or-patterns-back-compat.fixed12
-rw-r--r--src/test/ui/macros/macro-or-patterns-back-compat.rs6
-rw-r--r--src/test/ui/macros/macro-or-patterns-back-compat.stderr10
10 files changed, 35 insertions, 33 deletions
diff --git a/compiler/rustc_ast/src/token.rs b/compiler/rustc_ast/src/token.rs
index 10d48a55bb5..3bd2d0fa324 100644
--- a/compiler/rustc_ast/src/token.rs
+++ b/compiler/rustc_ast/src/token.rs
@@ -688,13 +688,13 @@ pub enum NonterminalKind {
     Item,
     Block,
     Stmt,
-    Pat2015 {
-        /// Keep track of whether the user used `:pat2015` or `:pat` and we inferred it from the
+    PatParam {
+        /// Keep track of whether the user used `:pat_param` or `:pat` and we inferred it from the
         /// edition of the span. This is used for diagnostics.
         inferred: bool,
     },
     Pat2021 {
-        /// Keep track of whether the user used `:pat2015` or `:pat` and we inferred it from the
+        /// Keep track of whether the user used `:pat_param` or `:pat` and we inferred it from the
         /// edition of the span. This is used for diagnostics.
         inferred: bool,
     },
@@ -722,11 +722,11 @@ impl NonterminalKind {
             sym::stmt => NonterminalKind::Stmt,
             sym::pat => match edition() {
                 Edition::Edition2015 | Edition::Edition2018 => {
-                    NonterminalKind::Pat2015 { inferred: true }
+                    NonterminalKind::PatParam { inferred: true }
                 }
                 Edition::Edition2021 => NonterminalKind::Pat2021 { inferred: true },
             },
-            sym::pat2015 => NonterminalKind::Pat2015 { inferred: false },
+            sym::pat_param => NonterminalKind::PatParam { inferred: false },
             sym::pat2021 => NonterminalKind::Pat2021 { inferred: false },
             sym::expr => NonterminalKind::Expr,
             sym::ty => NonterminalKind::Ty,
@@ -745,9 +745,9 @@ impl NonterminalKind {
             NonterminalKind::Item => sym::item,
             NonterminalKind::Block => sym::block,
             NonterminalKind::Stmt => sym::stmt,
-            NonterminalKind::Pat2015 { inferred: false } => sym::pat2015,
+            NonterminalKind::PatParam { inferred: false } => sym::pat_param,
             NonterminalKind::Pat2021 { inferred: false } => sym::pat2021,
-            NonterminalKind::Pat2015 { inferred: true }
+            NonterminalKind::PatParam { inferred: true }
             | NonterminalKind::Pat2021 { inferred: true } => sym::pat,
             NonterminalKind::Expr => sym::expr,
             NonterminalKind::Ty => sym::ty,
diff --git a/compiler/rustc_expand/src/mbe/macro_rules.rs b/compiler/rustc_expand/src/mbe/macro_rules.rs
index bc45c57596e..7a2fa3d2475 100644
--- a/compiler/rustc_expand/src/mbe/macro_rules.rs
+++ b/compiler/rustc_expand/src/mbe/macro_rules.rs
@@ -955,15 +955,15 @@ fn check_matcher_core(
             if let TokenTree::MetaVarDecl(span, name, Some(kind)) = *token {
                 for next_token in &suffix_first.tokens {
                     // Check if the old pat is used and the next token is `|`.
-                    if let NonterminalKind::Pat2015 { inferred: true } = kind {
+                    if let NonterminalKind::PatParam { inferred: true } = kind {
                         if let TokenTree::Token(token) = next_token {
                             if let BinOp(token) = token.kind {
                                 if let token::BinOpToken::Or = token {
-                                    // It is suggestion to use pat2015, for example: $x:pat -> $x:pat2015.
+                                    // It is suggestion to use pat_param, for example: $x:pat -> $x:pat_param.
                                     let suggestion = quoted_tt_to_string(&TokenTree::MetaVarDecl(
                                         span,
                                         name,
-                                        Some(NonterminalKind::Pat2015 { inferred: false }),
+                                        Some(NonterminalKind::PatParam { inferred: false }),
                                     ));
                                     sess.buffer_lint_with_diagnostic(
                                         &OR_PATTERNS_BACK_COMPAT,
@@ -1105,7 +1105,7 @@ fn is_in_follow(tok: &mbe::TokenTree, kind: NonterminalKind) -> IsInFollow {
                     _ => IsInFollow::No(TOKENS),
                 }
             }
-            NonterminalKind::Pat2015 { .. } => {
+            NonterminalKind::PatParam { .. } => {
                 const TOKENS: &[&str] = &["`=>`", "`,`", "`=`", "`|`", "`if`", "`in`"];
                 match tok {
                     TokenTree::Token(token) => match token.kind {
diff --git a/compiler/rustc_lint/src/context.rs b/compiler/rustc_lint/src/context.rs
index b3a19bfbf75..c1d6a4f1de1 100644
--- a/compiler/rustc_lint/src/context.rs
+++ b/compiler/rustc_lint/src/context.rs
@@ -710,7 +710,7 @@ pub trait LintContext: Sized {
                     db.note(&note);
                 }
                 BuiltinLintDiagnostics::OrPatternsBackCompat(span,suggestion) => {
-                    db.span_suggestion(span, "use pat2015 to preserve semantics", suggestion, Applicability::MachineApplicable);
+                    db.span_suggestion(span, "use pat_param to preserve semantics", suggestion, Applicability::MachineApplicable);
                 }
             }
             // Rewrap `db`, and pass control to the user.
diff --git a/compiler/rustc_parse/src/parser/nonterminal.rs b/compiler/rustc_parse/src/parser/nonterminal.rs
index 5c4a2785d6e..5635fbbb978 100644
--- a/compiler/rustc_parse/src/parser/nonterminal.rs
+++ b/compiler/rustc_parse/src/parser/nonterminal.rs
@@ -61,7 +61,8 @@ impl<'a> Parser<'a> {
                 },
                 _ => false,
             },
-            NonterminalKind::Pat2015 { .. } | NonterminalKind::Pat2021 { .. } => match token.kind {
+            NonterminalKind::PatParam { .. } | NonterminalKind::Pat2021 { .. } => {
+                match token.kind {
                 token::Ident(..) |                  // box, ref, mut, and other identifiers (can stricten)
                 token::OpenDelim(token::Paren) |    // tuple pattern
                 token::OpenDelim(token::Bracket) |  // slice pattern
@@ -78,7 +79,8 @@ impl<'a> Parser<'a> {
                 token::BinOp(token::Or) =>  matches!(kind, NonterminalKind::Pat2021 {..}),
                 token::Interpolated(ref nt) => may_be_ident(nt),
                 _ => false,
-            },
+            }
+            }
             NonterminalKind::Lifetime => match token.kind {
                 token::Lifetime(_) => true,
                 token::Interpolated(ref nt) => {
@@ -118,9 +120,9 @@ impl<'a> Parser<'a> {
                     return Err(self.struct_span_err(self.token.span, "expected a statement"));
                 }
             },
-            NonterminalKind::Pat2015 { .. } | NonterminalKind::Pat2021 { .. } => {
+            NonterminalKind::PatParam { .. } | NonterminalKind::Pat2021 { .. } => {
                 token::NtPat(self.collect_tokens_no_attrs(|this| match kind {
-                    NonterminalKind::Pat2015 { .. } => this.parse_pat_no_top_alt(None),
+                    NonterminalKind::PatParam { .. } => this.parse_pat_no_top_alt(None),
                     NonterminalKind::Pat2021 { .. } => {
                         this.parse_pat_allow_top_alt(None, RecoverComma::No)
                     }
diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs
index 42e521a20a3..db0d0b9966c 100644
--- a/compiler/rustc_span/src/symbol.rs
+++ b/compiler/rustc_span/src/symbol.rs
@@ -849,8 +849,8 @@ symbols! {
         partial_ord,
         passes,
         pat,
-        pat2015,
         pat2021,
+        pat_param,
         path,
         pattern_parentheses,
         phantom_data,
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 e9f813f83ae..fdd8626c760 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,7 +1,7 @@
 // Feature gate test for `edition_macro_pats` feature.
 
 macro_rules! foo {
-    ($x:pat2015) => {}; // ok
+    ($x:pat_param) => {}; // ok
     ($x:pat2021) => {}; //~ERROR `pat2021` is unstable
 }
 
diff --git a/src/test/ui/macros/edition-macro-pats.rs b/src/test/ui/macros/edition-macro-pats.rs
index 58f92710305..963a9c01a3b 100644
--- a/src/test/ui/macros/edition-macro-pats.rs
+++ b/src/test/ui/macros/edition-macro-pats.rs
@@ -3,7 +3,7 @@
 #![feature(edition_macro_pats)]
 
 macro_rules! foo {
-    (a $x:pat2015) => {};
+    (a $x:pat_param) => {};
     (b $x:pat2021) => {};
 }
 
diff --git a/src/test/ui/macros/macro-or-patterns-back-compat.fixed b/src/test/ui/macros/macro-or-patterns-back-compat.fixed
index f089f0fda4e..e0bd4cdde24 100644
--- a/src/test/ui/macros/macro-or-patterns-back-compat.fixed
+++ b/src/test/ui/macros/macro-or-patterns-back-compat.fixed
@@ -3,13 +3,13 @@
 #![feature(edition_macro_pats)]
 #![deny(or_patterns_back_compat)]
 #![allow(unused_macros)]
-macro_rules! foo { ($x:pat2015 | $y:pat) => {} } //~ ERROR the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro
-macro_rules! bar { ($($x:pat2015)+ | $($y:pat)+) => {} } //~ ERROR the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro
-macro_rules! baz { ($x:pat2015 | $y:pat2015) => {} } // should be ok
-macro_rules! qux { ($x:pat2015 | $y:pat) => {} } // should be ok
-macro_rules! ogg { ($x:pat2015 | $y:pat2015) => {} } //~ ERROR the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro
+macro_rules! foo { ($x:pat_param | $y:pat) => {} } //~ ERROR the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro
+macro_rules! bar { ($($x:pat_param)+ | $($y:pat)+) => {} } //~ ERROR the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro
+macro_rules! baz { ($x:pat_param | $y:pat_param) => {} } // should be ok
+macro_rules! qux { ($x:pat_param | $y:pat) => {} } // should be ok
+macro_rules! ogg { ($x:pat_param | $y:pat_param) => {} } //~ ERROR the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro
 macro_rules! match_any {
-    ( $expr:expr , $( $( $pat:pat2015 )|+ => $expr_arm:expr ),+ ) => { //~ ERROR the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro
+    ( $expr:expr , $( $( $pat:pat_param )|+ => $expr_arm:expr ),+ ) => { //~ ERROR the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro
         match $expr {
             $(
                 $( $pat => $expr_arm, )+
diff --git a/src/test/ui/macros/macro-or-patterns-back-compat.rs b/src/test/ui/macros/macro-or-patterns-back-compat.rs
index 0252581d5f1..9ff072dc323 100644
--- a/src/test/ui/macros/macro-or-patterns-back-compat.rs
+++ b/src/test/ui/macros/macro-or-patterns-back-compat.rs
@@ -5,9 +5,9 @@
 #![allow(unused_macros)]
 macro_rules! foo { ($x:pat | $y:pat) => {} } //~ ERROR the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro
 macro_rules! bar { ($($x:pat)+ | $($y:pat)+) => {} } //~ ERROR the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro
-macro_rules! baz { ($x:pat2015 | $y:pat2015) => {} } // should be ok
-macro_rules! qux { ($x:pat2015 | $y:pat) => {} } // should be ok
-macro_rules! ogg { ($x:pat | $y:pat2015) => {} } //~ ERROR the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro
+macro_rules! baz { ($x:pat_param | $y:pat_param) => {} } // should be ok
+macro_rules! qux { ($x:pat_param | $y:pat) => {} } // should be ok
+macro_rules! ogg { ($x:pat | $y:pat_param) => {} } //~ ERROR the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro
 macro_rules! match_any {
     ( $expr:expr , $( $( $pat:pat )|+ => $expr_arm:expr ),+ ) => { //~ ERROR the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro
         match $expr {
diff --git a/src/test/ui/macros/macro-or-patterns-back-compat.stderr b/src/test/ui/macros/macro-or-patterns-back-compat.stderr
index d8f19fa5807..970f62f6cff 100644
--- a/src/test/ui/macros/macro-or-patterns-back-compat.stderr
+++ b/src/test/ui/macros/macro-or-patterns-back-compat.stderr
@@ -2,7 +2,7 @@ error: the meaning of the `pat` fragment specifier is changing in Rust 2021, whi
   --> $DIR/macro-or-patterns-back-compat.rs:6:21
    |
 LL | macro_rules! foo { ($x:pat | $y:pat) => {} }
-   |                     ^^^^^^ help: use pat2015 to preserve semantics: `$x:pat2015`
+   |                     ^^^^^^ help: use pat_param to preserve semantics: `$x:pat_param`
    |
 note: the lint level is defined here
   --> $DIR/macro-or-patterns-back-compat.rs:4:9
@@ -14,19 +14,19 @@ error: the meaning of the `pat` fragment specifier is changing in Rust 2021, whi
   --> $DIR/macro-or-patterns-back-compat.rs:7:23
    |
 LL | macro_rules! bar { ($($x:pat)+ | $($y:pat)+) => {} }
-   |                       ^^^^^^ help: use pat2015 to preserve semantics: `$x:pat2015`
+   |                       ^^^^^^ help: use pat_param to preserve semantics: `$x:pat_param`
 
 error: the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro
   --> $DIR/macro-or-patterns-back-compat.rs:10:21
    |
-LL | macro_rules! ogg { ($x:pat | $y:pat2015) => {} }
-   |                     ^^^^^^ help: use pat2015 to preserve semantics: `$x:pat2015`
+LL | macro_rules! ogg { ($x:pat | $y:pat_param) => {} }
+   |                     ^^^^^^ help: use pat_param to preserve semantics: `$x:pat_param`
 
 error: the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro
   --> $DIR/macro-or-patterns-back-compat.rs:12:26
    |
 LL |     ( $expr:expr , $( $( $pat:pat )|+ => $expr_arm:expr ),+ ) => {
-   |                          ^^^^^^^^ help: use pat2015 to preserve semantics: `$pat:pat2015`
+   |                          ^^^^^^^^ help: use pat_param to preserve semantics: `$pat:pat_param`
 
 error: aborting due to 4 previous errors