Rollup merge of #81888 - ehuss:macro_rules-pp, r=petrochenkov

Fix pretty printer macro_rules with semicolon.

The pretty printer was not including the trailing semicolon for a macro_rules definition that used parenthesis or brackets, which results in invalid code. This adds the semicolon in those two cases.
This commit is contained in:
Dylan DPC 2021-02-09 02:40:05 +01:00 committed by GitHub
commit 78c0153757
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 0 deletions

View File

@ -1311,6 +1311,9 @@ impl<'a> State<'a> {
true,
item.span,
);
if macro_def.body.need_semicolon() {
self.word(";");
}
}
}
self.ann.post(self, AnnNode::Item(item))

View File

@ -0,0 +1,19 @@
// pp-exact
macro_rules! brace { () => { } ; }
macro_rules! bracket[() => { } ;];
macro_rules! paren(() => { } ;);
macro_rules! matcher_brackets {
(paren) => { } ; (bracket) => { } ; (brace) => { } ;
}
macro_rules! all_fragments {
($ b : block, $ e : expr, $ i : ident, $ it : item, $ l : lifetime, $ lit
: literal, $ m : meta, $ p : pat, $ pth : path, $ s : stmt, $ tt : tt, $
ty : ty, $ vis : vis) => { } ;
}
fn main() { }