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

Commit 6efc963

Browse files
authored
Merge pull request rust-lang#3188 from scampi/issue3124
do not add a newline after a missed span if it is the end of a block comment
2 parents c4cc479 + f570438 commit 6efc963

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/missed_spans.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,8 @@ impl<'a> FmtVisitor<'a> {
260260
status.line_start = offset + subslice.len();
261261

262262
if let Some('/') = subslice.chars().nth(1) {
263-
// check that there are no contained block comments
264-
if !subslice.lines().any(|s| s.trim_left().starts_with("/*")) {
265-
// Add a newline after line comments
263+
// Only add a newline if the last line is a line comment
264+
if !subslice.trim_end().ends_with("*/") {
266265
self.push_str("\n");
267266
}
268267
} else if status.line_start <= snippet.len() {

tests/target/issue-3124.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
pub fn fail1() {
2+
// Some comment.
3+
/**///
4+
}
5+
6+
pub fn fail2() {
7+
// Some comment.
8+
/**/
9+
}
10+
11+
pub fn fail3() {
12+
// Some comment.
13+
//
14+
}

0 commit comments

Comments
 (0)