Skip to content

Commit f6b499d

Browse files
Suggest the pat_param specifier before | on 2021 edition
We have a migration warning but no lint for users who have enabled the new edition.
1 parent 6db0a0e commit f6b499d

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

compiler/rustc_expand/src/mbe/macro_rules.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,6 +1027,24 @@ fn check_matcher_core(
10271027
),
10281028
);
10291029
err.span_label(sp, format!("not allowed after `{}` fragments", kind));
1030+
1031+
if kind == NonterminalKind::PatWithOr
1032+
&& sess.edition == Edition::Edition2021
1033+
&& next_token.is_token(&BinOp(token::BinOpToken::Or))
1034+
{
1035+
let suggestion = quoted_tt_to_string(&TokenTree::MetaVarDecl(
1036+
span,
1037+
name,
1038+
Some(NonterminalKind::PatParam { inferred: false }),
1039+
));
1040+
err.span_suggestion(
1041+
span,
1042+
&format!("try a `pat_param` fragment specifier instead"),
1043+
suggestion,
1044+
Applicability::MaybeIncorrect,
1045+
);
1046+
}
1047+
10301048
let msg = "allowed there are: ";
10311049
match possible {
10321050
&[] => {}

0 commit comments

Comments
 (0)