1
Fork 0

Rollup merge of #113999 - Centri3:macro-arm-expand, r=wesleywiser

Specify macro is invalid in certain contexts

Adds a note when a macro is used where it really shouldn't be.

Closes #113766
This commit is contained in:
Matthias Krüger 2023-08-04 07:25:45 +02:00 committed by GitHub
commit 1f076fe1d8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 246 additions and 24 deletions

View file

@ -142,7 +142,11 @@ impl<'a> Parser<'a> {
// Parse the first pattern (`p_0`).
let mut first_pat = self.parse_pat_no_top_alt(expected, syntax_loc)?;
if rc == RecoverComma::Yes {
self.maybe_recover_unexpected_comma(first_pat.span, rt)?;
self.maybe_recover_unexpected_comma(
first_pat.span,
matches!(first_pat.kind, PatKind::MacCall(_)),
rt,
)?;
}
// If the next token is not a `|`,
@ -184,7 +188,7 @@ impl<'a> Parser<'a> {
err
})?;
if rc == RecoverComma::Yes {
self.maybe_recover_unexpected_comma(pat.span, rt)?;
self.maybe_recover_unexpected_comma(pat.span, false, rt)?;
}
pats.push(pat);
}