Skip to content

Commit

Permalink
Fix pretty printer macro_rules with semicolon.
Browse files Browse the repository at this point in the history
  • Loading branch information
ehuss committed Feb 8, 2021
1 parent 921ec4b commit cadffa7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
3 changes: 3 additions & 0 deletions compiler/rustc_ast_pretty/src/pprust/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
19 changes: 19 additions & 0 deletions src/test/pretty/macro_rules.rs
Original file line number Diff line number Diff line change
@@ -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() { }

0 comments on commit cadffa7

Please sign in to comment.