Skip to content

Commit

Permalink
Suppress space after idents with "ModName" style in serialization of …
Browse files Browse the repository at this point in the history
…exported macros.

Fixes issue #20701
  • Loading branch information
vadimcn committed Jan 23, 2015
1 parent b7930d9 commit 27a261b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/libsyntax/print/pprust.rs
Expand Up @@ -1164,11 +1164,20 @@ impl<'a> State<'a> {

pub fn print_tts(&mut self, tts: &[ast::TokenTree]) -> IoResult<()> {
try!(self.ibox(0));
let mut suppress_space = false;
for (i, tt) in tts.iter().enumerate() {
if i != 0 {
if i != 0 && !suppress_space {
try!(space(&mut self.s));
}
try!(self.print_tt(tt));
// There should be no space between the module name and the following `::` in paths,
// otherwise imported macros get re-parsed from crate metadata incorrectly (issue #20701)
suppress_space = match tt {
&ast::TtToken(_, token::Ident(_, token::ModName)) |
&ast::TtToken(_, token::MatchNt(_, _, _, token::ModName)) |
&ast::TtToken(_, token::SubstNt(_, token::ModName)) => true,
_ => false
}
}
self.end()
}
Expand Down

0 comments on commit 27a261b

Please sign in to comment.