Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/missed_spans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,15 +270,15 @@ impl<'a> FmtVisitor<'a> {
if on_same_line {
match subslice.find('\n') {
None => {
self.push_str(subslice);
self.push_str(subslice.trim_end());
}
Some(offset) if offset + 1 == subslice.len() => {
self.push_str(&subslice[..offset]);
self.push_str(&subslice[..offset].trim_end());
}
Some(offset) => {
// keep first line as is: if it were too long and wrapped, it may get mixed
// with the other lines.
let first_line = &subslice[..offset];
let first_line = &subslice[..offset].trim_end();
self.push_str(first_line);
self.push_str(&comment_indent.to_string_with_newline(self.config));

Expand Down
3 changes: 3 additions & 0 deletions tests/source/issue_6568.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// rustfmt-style_edition: 2024

fn f() {} // This has trailing whitespace
3 changes: 3 additions & 0 deletions tests/target/issue_6568.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// rustfmt-style_edition: 2024

fn f() {} // This has trailing whitespace
Loading