Skip to content

Commit 0566ccc

Browse files
committed
rename pat2015 to pat_param
1 parent ebc4ace commit 0566ccc

File tree

10 files changed

+35
-33
lines changed

10 files changed

+35
-33
lines changed

compiler/rustc_ast/src/token.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -688,13 +688,13 @@ pub enum NonterminalKind {
688688
Item,
689689
Block,
690690
Stmt,
691-
Pat2015 {
692-
/// Keep track of whether the user used `:pat2015` or `:pat` and we inferred it from the
691+
PatParam {
692+
/// Keep track of whether the user used `:pat_param` or `:pat` and we inferred it from the
693693
/// edition of the span. This is used for diagnostics.
694694
inferred: bool,
695695
},
696696
Pat2021 {
697-
/// Keep track of whether the user used `:pat2015` or `:pat` and we inferred it from the
697+
/// Keep track of whether the user used `:pat_param` or `:pat` and we inferred it from the
698698
/// edition of the span. This is used for diagnostics.
699699
inferred: bool,
700700
},
@@ -722,11 +722,11 @@ impl NonterminalKind {
722722
sym::stmt => NonterminalKind::Stmt,
723723
sym::pat => match edition() {
724724
Edition::Edition2015 | Edition::Edition2018 => {
725-
NonterminalKind::Pat2015 { inferred: true }
725+
NonterminalKind::PatParam { inferred: true }
726726
}
727727
Edition::Edition2021 => NonterminalKind::Pat2021 { inferred: true },
728728
},
729-
sym::pat2015 => NonterminalKind::Pat2015 { inferred: false },
729+
sym::pat_param => NonterminalKind::PatParam { inferred: false },
730730
sym::pat2021 => NonterminalKind::Pat2021 { inferred: false },
731731
sym::expr => NonterminalKind::Expr,
732732
sym::ty => NonterminalKind::Ty,
@@ -745,9 +745,9 @@ impl NonterminalKind {
745745
NonterminalKind::Item => sym::item,
746746
NonterminalKind::Block => sym::block,
747747
NonterminalKind::Stmt => sym::stmt,
748-
NonterminalKind::Pat2015 { inferred: false } => sym::pat2015,
748+
NonterminalKind::PatParam { inferred: false } => sym::pat_param,
749749
NonterminalKind::Pat2021 { inferred: false } => sym::pat2021,
750-
NonterminalKind::Pat2015 { inferred: true }
750+
NonterminalKind::PatParam { inferred: true }
751751
| NonterminalKind::Pat2021 { inferred: true } => sym::pat,
752752
NonterminalKind::Expr => sym::expr,
753753
NonterminalKind::Ty => sym::ty,

compiler/rustc_expand/src/mbe/macro_rules.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -955,15 +955,15 @@ fn check_matcher_core(
955955
if let TokenTree::MetaVarDecl(span, name, Some(kind)) = *token {
956956
for next_token in &suffix_first.tokens {
957957
// Check if the old pat is used and the next token is `|`.
958-
if let NonterminalKind::Pat2015 { inferred: true } = kind {
958+
if let NonterminalKind::PatParam { inferred: true } = kind {
959959
if let TokenTree::Token(token) = next_token {
960960
if let BinOp(token) = token.kind {
961961
if let token::BinOpToken::Or = token {
962-
// It is suggestion to use pat2015, for example: $x:pat -> $x:pat2015.
962+
// It is suggestion to use pat_param, for example: $x:pat -> $x:pat_param.
963963
let suggestion = quoted_tt_to_string(&TokenTree::MetaVarDecl(
964964
span,
965965
name,
966-
Some(NonterminalKind::Pat2015 { inferred: false }),
966+
Some(NonterminalKind::PatParam { inferred: false }),
967967
));
968968
sess.buffer_lint_with_diagnostic(
969969
&OR_PATTERNS_BACK_COMPAT,
@@ -1105,7 +1105,7 @@ fn is_in_follow(tok: &mbe::TokenTree, kind: NonterminalKind) -> IsInFollow {
11051105
_ => IsInFollow::No(TOKENS),
11061106
}
11071107
}
1108-
NonterminalKind::Pat2015 { .. } => {
1108+
NonterminalKind::PatParam { .. } => {
11091109
const TOKENS: &[&str] = &["`=>`", "`,`", "`=`", "`|`", "`if`", "`in`"];
11101110
match tok {
11111111
TokenTree::Token(token) => match token.kind {

compiler/rustc_lint/src/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ pub trait LintContext: Sized {
710710
db.note(&note);
711711
}
712712
BuiltinLintDiagnostics::OrPatternsBackCompat(span,suggestion) => {
713-
db.span_suggestion(span, "use pat2015 to preserve semantics", suggestion, Applicability::MachineApplicable);
713+
db.span_suggestion(span, "use pat_param to preserve semantics", suggestion, Applicability::MachineApplicable);
714714
}
715715
}
716716
// Rewrap `db`, and pass control to the user.

compiler/rustc_parse/src/parser/nonterminal.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ impl<'a> Parser<'a> {
6161
},
6262
_ => false,
6363
},
64-
NonterminalKind::Pat2015 { .. } | NonterminalKind::Pat2021 { .. } => match token.kind {
64+
NonterminalKind::PatParam { .. } | NonterminalKind::Pat2021 { .. } => {
65+
match token.kind {
6566
token::Ident(..) | // box, ref, mut, and other identifiers (can stricten)
6667
token::OpenDelim(token::Paren) | // tuple pattern
6768
token::OpenDelim(token::Bracket) | // slice pattern
@@ -78,7 +79,8 @@ impl<'a> Parser<'a> {
7879
token::BinOp(token::Or) => matches!(kind, NonterminalKind::Pat2021 {..}),
7980
token::Interpolated(ref nt) => may_be_ident(nt),
8081
_ => false,
81-
},
82+
}
83+
}
8284
NonterminalKind::Lifetime => match token.kind {
8385
token::Lifetime(_) => true,
8486
token::Interpolated(ref nt) => {
@@ -118,9 +120,9 @@ impl<'a> Parser<'a> {
118120
return Err(self.struct_span_err(self.token.span, "expected a statement"));
119121
}
120122
},
121-
NonterminalKind::Pat2015 { .. } | NonterminalKind::Pat2021 { .. } => {
123+
NonterminalKind::PatParam { .. } | NonterminalKind::Pat2021 { .. } => {
122124
token::NtPat(self.collect_tokens_no_attrs(|this| match kind {
123-
NonterminalKind::Pat2015 { .. } => this.parse_pat_no_top_alt(None),
125+
NonterminalKind::PatParam { .. } => this.parse_pat_no_top_alt(None),
124126
NonterminalKind::Pat2021 { .. } => {
125127
this.parse_pat_allow_top_alt(None, RecoverComma::No)
126128
}

compiler/rustc_span/src/symbol.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -849,8 +849,8 @@ symbols! {
849849
partial_ord,
850850
passes,
851851
pat,
852-
pat2015,
853852
pat2021,
853+
pat_param,
854854
path,
855855
pattern_parentheses,
856856
phantom_data,

src/test/ui/feature-gates/feature-gate-edition_macro_pats.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Feature gate test for `edition_macro_pats` feature.
22

33
macro_rules! foo {
4-
($x:pat2015) => {}; // ok
4+
($x:pat_param) => {}; // ok
55
($x:pat2021) => {}; //~ERROR `pat2021` is unstable
66
}
77

src/test/ui/macros/edition-macro-pats.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#![feature(edition_macro_pats)]
44

55
macro_rules! foo {
6-
(a $x:pat2015) => {};
6+
(a $x:pat_param) => {};
77
(b $x:pat2021) => {};
88
}
99

src/test/ui/macros/macro-or-patterns-back-compat.fixed

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
#![feature(edition_macro_pats)]
44
#![deny(or_patterns_back_compat)]
55
#![allow(unused_macros)]
6-
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
7-
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
8-
macro_rules! baz { ($x:pat2015 | $y:pat2015) => {} } // should be ok
9-
macro_rules! qux { ($x:pat2015 | $y:pat) => {} } // should be ok
10-
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
6+
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
7+
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
8+
macro_rules! baz { ($x:pat_param | $y:pat_param) => {} } // should be ok
9+
macro_rules! qux { ($x:pat_param | $y:pat) => {} } // should be ok
10+
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
1111
macro_rules! match_any {
12-
( $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
12+
( $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
1313
match $expr {
1414
$(
1515
$( $pat => $expr_arm, )+

src/test/ui/macros/macro-or-patterns-back-compat.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
#![allow(unused_macros)]
66
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
77
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
8-
macro_rules! baz { ($x:pat2015 | $y:pat2015) => {} } // should be ok
9-
macro_rules! qux { ($x:pat2015 | $y:pat) => {} } // should be ok
10-
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
8+
macro_rules! baz { ($x:pat_param | $y:pat_param) => {} } // should be ok
9+
macro_rules! qux { ($x:pat_param | $y:pat) => {} } // should be ok
10+
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
1111
macro_rules! match_any {
1212
( $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
1313
match $expr {

src/test/ui/macros/macro-or-patterns-back-compat.stderr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: the meaning of the `pat` fragment specifier is changing in Rust 2021, whi
22
--> $DIR/macro-or-patterns-back-compat.rs:6:21
33
|
44
LL | macro_rules! foo { ($x:pat | $y:pat) => {} }
5-
| ^^^^^^ help: use pat2015 to preserve semantics: `$x:pat2015`
5+
| ^^^^^^ help: use pat_param to preserve semantics: `$x:pat_param`
66
|
77
note: the lint level is defined here
88
--> $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
1414
--> $DIR/macro-or-patterns-back-compat.rs:7:23
1515
|
1616
LL | macro_rules! bar { ($($x:pat)+ | $($y:pat)+) => {} }
17-
| ^^^^^^ help: use pat2015 to preserve semantics: `$x:pat2015`
17+
| ^^^^^^ help: use pat_param to preserve semantics: `$x:pat_param`
1818

1919
error: the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro
2020
--> $DIR/macro-or-patterns-back-compat.rs:10:21
2121
|
22-
LL | macro_rules! ogg { ($x:pat | $y:pat2015) => {} }
23-
| ^^^^^^ help: use pat2015 to preserve semantics: `$x:pat2015`
22+
LL | macro_rules! ogg { ($x:pat | $y:pat_param) => {} }
23+
| ^^^^^^ help: use pat_param to preserve semantics: `$x:pat_param`
2424

2525
error: the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro
2626
--> $DIR/macro-or-patterns-back-compat.rs:12:26
2727
|
2828
LL | ( $expr:expr , $( $( $pat:pat )|+ => $expr_arm:expr ),+ ) => {
29-
| ^^^^^^^^ help: use pat2015 to preserve semantics: `$pat:pat2015`
29+
| ^^^^^^^^ help: use pat_param to preserve semantics: `$pat:pat_param`
3030

3131
error: aborting due to 4 previous errors
3232

0 commit comments

Comments
 (0)