From 86f80d3ba8d81b29e66ad415219e60c3f1d48a6b Mon Sep 17 00:00:00 2001 From: David Wood Date: Sun, 2 Aug 2020 15:27:03 +0100 Subject: [PATCH] pprust: adjust mixed comment printing This commit adjusts the pretty printing of mixed comments so that the initial zero-break isn't emitted at the beginning of the line. Through this, the `block-comment-wchar` test can have the `pp-exact` file removed, as it no longer converges from pretty printing of the source. Signed-off-by: David Wood --- src/librustc_ast_pretty/pprust.rs | 4 +++- src/test/pretty/block-comment-wchar.pp | 2 -- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/librustc_ast_pretty/pprust.rs b/src/librustc_ast_pretty/pprust.rs index b0edb1ca41d..4b228629ad7 100644 --- a/src/librustc_ast_pretty/pprust.rs +++ b/src/librustc_ast_pretty/pprust.rs @@ -450,7 +450,9 @@ pub trait PrintState<'a>: std::ops::Deref + std::ops::Dere fn print_comment(&mut self, cmnt: &comments::Comment) { match cmnt.style { comments::Mixed => { - self.zerobreak(); + if !self.is_beginning_of_line() { + self.zerobreak(); + } if let Some((last, lines)) = cmnt.lines.split_last() { self.ibox(0); diff --git a/src/test/pretty/block-comment-wchar.pp b/src/test/pretty/block-comment-wchar.pp index 9317b36ba49..2bfcdd75e15 100644 --- a/src/test/pretty/block-comment-wchar.pp +++ b/src/test/pretty/block-comment-wchar.pp @@ -73,7 +73,6 @@ fn f() { */ - /* */ /* @@ -81,7 +80,6 @@ fn f() { Space 6+2: compare A Ogham Space Mark 6+2: compare B */ - /* */ /*