Skip to content

Commit 27a261b

Browse files
committed
Suppress space after idents with "ModName" style in serialization of exported macros.
Fixes issue #20701
1 parent b7930d9 commit 27a261b

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/libsyntax/print/pprust.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1164,11 +1164,20 @@ impl<'a> State<'a> {
11641164

11651165
pub fn print_tts(&mut self, tts: &[ast::TokenTree]) -> IoResult<()> {
11661166
try!(self.ibox(0));
1167+
let mut suppress_space = false;
11671168
for (i, tt) in tts.iter().enumerate() {
1168-
if i != 0 {
1169+
if i != 0 && !suppress_space {
11691170
try!(space(&mut self.s));
11701171
}
11711172
try!(self.print_tt(tt));
1173+
// There should be no space between the module name and the following `::` in paths,
1174+
// otherwise imported macros get re-parsed from crate metadata incorrectly (issue #20701)
1175+
suppress_space = match tt {
1176+
&ast::TtToken(_, token::Ident(_, token::ModName)) |
1177+
&ast::TtToken(_, token::MatchNt(_, _, _, token::ModName)) |
1178+
&ast::TtToken(_, token::SubstNt(_, token::ModName)) => true,
1179+
_ => false
1180+
}
11721181
}
11731182
self.end()
11741183
}

0 commit comments

Comments
 (0)