Skip to content

Commit

Permalink
Fix #2346: empty comments should not have any trailing space added
Browse files Browse the repository at this point in the history
  • Loading branch information
karyon committed Feb 18, 2018
1 parent 263104a commit 8e36d54
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion rustfmt-core/src/comment.rs
Expand Up @@ -466,7 +466,7 @@ fn rewrite_comment_inner(
}

result.push_str(closer);
if result == opener && result.ends_with(' ') {
if result.ends_with(opener) && opener.ends_with(' ') {
// Trailing space.
result.pop();
}
Expand Down
4 changes: 4 additions & 0 deletions rustfmt-core/tests/target/issue-2346.rs
@@ -0,0 +1,4 @@
// rustfmt-normalize_comments: true
// the following empty comment should not have any trailing space added.
//
fn main() {}

0 comments on commit 8e36d54

Please sign in to comment.