Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit dd14d30

Browse files
committed
discard trailing blank comments
1 parent f23e6aa commit dd14d30

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/comment.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,8 +449,12 @@ fn rewrite_comment_inner(
449449
}
450450
} else if is_prev_line_multi_line && !line.is_empty() {
451451
result.push(' ')
452-
} else if is_last && !closer.is_empty() && line.is_empty() {
453-
result.push_str(&indent_str);
452+
} else if is_last && line.is_empty() {
453+
// trailing blank lines are unwanted
454+
if !closer.is_empty() {
455+
result.push_str(&indent_str);
456+
}
457+
break;
454458
} else {
455459
result.push_str(&comment_line_separator);
456460
if !has_leading_whitespace && result.ends_with(' ') {

tests/target/doc-comment-with-example.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,4 @@
88
/// # #![cfg_attr(not(dox), no_std)]
99
/// fn foo() {}
1010
/// ```
11-
///
1211
fn foo() {}

0 commit comments

Comments
 (0)