Skip to content

Commit

Permalink
Merge pull request rust-lang#3188 from scampi/issue3124
Browse files Browse the repository at this point in the history
do not add a newline after a missed span if it is the end of a block comment
  • Loading branch information
nrc authored Nov 9, 2018
2 parents c4cc479 + f570438 commit 6efc963
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/missed_spans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,8 @@ impl<'a> FmtVisitor<'a> {
status.line_start = offset + subslice.len();

if let Some('/') = subslice.chars().nth(1) {
// check that there are no contained block comments
if !subslice.lines().any(|s| s.trim_left().starts_with("/*")) {
// Add a newline after line comments
// Only add a newline if the last line is a line comment
if !subslice.trim_end().ends_with("*/") {
self.push_str("\n");
}
} else if status.line_start <= snippet.len() {
Expand Down
14 changes: 14 additions & 0 deletions tests/target/issue-3124.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
pub fn fail1() {
// Some comment.
/**///
}

pub fn fail2() {
// Some comment.
/**/
}

pub fn fail3() {
// Some comment.
//
}

0 comments on commit 6efc963

Please sign in to comment.