Skip to content

Commit 89dce46

Browse files
authored
Rollup merge of #63198 - rbartlensky:fix-macro-trailing-comma, r=petrochenkov
Allow trailing comma in macro 2.0 declarations. This should hopefully close #63102.
2 parents dbfe12d + 2aa368a commit 89dce46

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/libsyntax/ext/tt/macro_rules.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,10 @@ pub fn compile(
282282
quoted::TokenTree::Sequence(
283283
DelimSpan::dummy(),
284284
Lrc::new(quoted::SequenceRepetition {
285-
tts: vec![quoted::TokenTree::token(token::Semi, def.span)],
285+
tts: vec![quoted::TokenTree::token(
286+
if body.legacy { token::Semi } else { token::Comma },
287+
def.span,
288+
)],
286289
separator: None,
287290
kleene: quoted::KleeneToken::new(quoted::KleeneOp::ZeroOrMore, def.span),
288291
num_captures: 0,

src/test/ui/macros/issue-63102.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// check-pass
2+
3+
#![feature(decl_macro)]
4+
macro foo {
5+
() => {},
6+
}
7+
8+
fn main() {}

0 commit comments

Comments
 (0)