diff options
| author | bors <bors@rust-lang.org> | 2019-09-14 02:19:28 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-09-14 02:19:28 +0000 |
| commit | fdd48565d0c8a9e6fedd8c6db951ee46577b5f54 (patch) | |
| tree | 5d5b9d1cae0f42ae984aa492c94d820461e88145 /src/libsyntax/print | |
| parent | d097af105526a8defe413c64d79766333bb2085b (diff) | |
| parent | e0862784a1550dc1e07249c8967179a09b091141 (diff) | |
Auto merge of #64438 - cuviper:beta-rollup, r=Mark-Simulacrum
[beta] Rollup backports Cherry-picked: - Permit unwinding through FFI by default #62603 - pprust: Do not print spaces before some tokens #63897 - Account for doc comments coming from proc macros without spans #63930 - Support "soft" feature-gating using a lint #64066 - Update xLTO compatibility table in rustc book. #64092 - Include compiler-rt in the source tarball #64240 - Update LLVM submodule #64317 r? @Mark-Simulacrum
Diffstat (limited to 'src/libsyntax/print')
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index bda761244d5..536687bdbed 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -152,6 +152,18 @@ pub fn to_string<F>(f: F) -> String where printer.s.eof() } +// This makes comma-separated lists look slightly nicer, +// and also addresses a specific regression described in issue #63896. +fn tt_prepend_space(tt: &TokenTree) -> bool { + match tt { + TokenTree::Token(token) => match token.kind { + token::Comma => false, + _ => true, + } + _ => true, + } +} + fn binop_to_string(op: BinOpToken) -> &'static str { match op { token::Plus => "+", @@ -684,7 +696,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target=pp::Printer> + std::ops::DerefM fn print_tts(&mut self, tts: tokenstream::TokenStream, convert_dollar_crate: bool) { for (i, tt) in tts.into_trees().enumerate() { - if i != 0 { + if i != 0 && tt_prepend_space(&tt) { self.space(); } self.print_tt(tt, convert_dollar_crate); |
