Auto merge of #83386 - mark-i-m:stabilize-pat2015, r=nikomatsakis
Stabilize `:pat_param` and remove `:pat2021` Blocked on #83384 cc `@rust-lang/lang` #79278 If I understand `@nikomatsakis` in https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/or.20patterns/near/231133873, another FCP is not needed. r? `@nikomatsakis`
This commit is contained in:
commit
ca075d268d
15 changed files with 66 additions and 121 deletions
|
@ -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 {
|
||||
|
@ -1116,7 +1116,7 @@ fn is_in_follow(tok: &mbe::TokenTree, kind: NonterminalKind) -> IsInFollow {
|
|||
_ => IsInFollow::No(TOKENS),
|
||||
}
|
||||
}
|
||||
NonterminalKind::Pat2021 { .. } => {
|
||||
NonterminalKind::PatWithOr { .. } => {
|
||||
const TOKENS: &[&str] = &["`=>`", "`,`", "`=`", "`if`", "`in`"];
|
||||
match tok {
|
||||
TokenTree::Token(token) => match token.kind {
|
||||
|
|
|
@ -6,8 +6,8 @@ use rustc_ast::tokenstream;
|
|||
use rustc_ast::{NodeId, DUMMY_NODE_ID};
|
||||
use rustc_ast_pretty::pprust;
|
||||
use rustc_feature::Features;
|
||||
use rustc_session::parse::{feature_err, ParseSess};
|
||||
use rustc_span::symbol::{kw, sym, Ident};
|
||||
use rustc_session::parse::ParseSess;
|
||||
use rustc_span::symbol::{kw, Ident};
|
||||
|
||||
use rustc_span::Span;
|
||||
|
||||
|
@ -62,21 +62,6 @@ 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();
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
let kind =
|
||||
token::NonterminalKind::from_symbol(frag.name, || {
|
||||
span.edition()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue