]> git.lizzy.rs Git - rust.git/commitdiff
discard trailing blank comments
authorStéphane Campinas <stephane.campinas@gmail.com>
Thu, 16 Aug 2018 17:59:32 +0000 (19:59 +0200)
committerStéphane Campinas <stephane.campinas@gmail.com>
Thu, 16 Aug 2018 17:59:32 +0000 (19:59 +0200)
src/comment.rs
tests/target/doc-comment-with-example.rs

index e9d91818d0dd58834330e192d1737fe1d9f14545..4f2f813166b09d1080cd03fa0635d1804d100316 100644 (file)
@@ -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(' ') {
index 720e337ad4edfba8fac61cc7b9f4b0b48840684b..bdf2adf0c6437b721428386a2b48149526eb1f72 100644 (file)
@@ -8,5 +8,4 @@
 /// # #![cfg_attr(not(dox), no_std)]
 /// fn foo() {}
 /// ```
-///
 fn foo() {}