From: Stéphane Campinas Date: Thu, 16 Aug 2018 17:59:32 +0000 (+0200) Subject: discard trailing blank comments X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=dd14d304ef27c2aa209e1138ac371d7f27b7a012;p=rust.git discard trailing blank comments --- diff --git a/src/comment.rs b/src/comment.rs index e9d91818d0d..4f2f813166b 100644 --- a/src/comment.rs +++ b/src/comment.rs @@ -449,8 +449,12 @@ fn rewrite_comment_inner( } } else if is_prev_line_multi_line && !line.is_empty() { result.push(' ') - } else if is_last && !closer.is_empty() && line.is_empty() { - result.push_str(&indent_str); + } else if is_last && line.is_empty() { + // trailing blank lines are unwanted + if !closer.is_empty() { + result.push_str(&indent_str); + } + break; } else { result.push_str(&comment_line_separator); if !has_leading_whitespace && result.ends_with(' ') { diff --git a/tests/target/doc-comment-with-example.rs b/tests/target/doc-comment-with-example.rs index 720e337ad4e..bdf2adf0c64 100644 --- a/tests/target/doc-comment-with-example.rs +++ b/tests/target/doc-comment-with-example.rs @@ -8,5 +8,4 @@ /// # #![cfg_attr(not(dox), no_std)] /// fn foo() {} /// ``` -/// fn foo() {}