diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index e80297eb797e5..759b16c5738f3 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1781,11 +1781,8 @@ impl<'a> State<'a> { token::Paren => try!(self.popen()), token::Bracket => try!(word(&mut self.s, "[")), token::Brace => { - // head-ibox, will be closed by bopen() - try!(self.ibox(0)); - // Don't ask me why the regular bopen() does - // more then just opening a brace... - try!(self.bopen()) + try!(self.head("")); + try!(self.bopen()); } } try!(self.print_tts(&m.node.tts)); diff --git a/src/test/pretty/issue-30731.rs b/src/test/pretty/issue-30731.rs new file mode 100644 index 0000000000000..cd72ae9843351 --- /dev/null +++ b/src/test/pretty/issue-30731.rs @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +// +// Test pretty printing of macro with braces but without terminating semicolon, +// this used to panic before fix. + +// pretty-compare-only +// pp-exact + +fn main() { b!{ } c }