diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 778f77ac7a818..8ba0191464886 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -58,7 +58,14 @@ impl Ident { impl Show for Ident { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "\"{}\"#{}", token::get_ident(*self).get(), self.ctxt) + write!(f, "{}#{}", self.name, self.ctxt) + } +} + +impl Show for Name { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let Name(nm) = *self; + write!(f, "\"{}\"({})", token::get_name(*self).get(), nm) } } @@ -106,7 +113,7 @@ pub static ILLEGAL_CTXT : SyntaxContext = 1; /// A name is a part of an identifier, representing a string or gensym. It's /// the result of interning. -#[deriving(Eq, Ord, PartialEq, PartialOrd, Hash, Encodable, Decodable, Clone, Show)] +#[deriving(Eq, Ord, PartialEq, PartialOrd, Hash, Encodable, Decodable, Clone)] pub struct Name(pub u32); impl Name { diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 9589a92348585..39034a3f8f21a 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -864,6 +864,11 @@ impl<'a> State<'a> { self.end() // close the outer-box } else { try!(self.nbsp()); + if struct_def.fields.len() == 0 { + try!(self.s.print_str(";")); + return Ok(()); + } + try!(self.bopen()); try!(self.hardbreak_if_not_bol());