Open
Description
When having wrap_comments = true
, running rustfmt on the following code produces an error:
fn f() {
g({
// some trailing spaces on the line below - this needs to be inside the g call
SomeStruct {
a: b, // // This needs two sets of the slash-slash comments, and this needs to be a very long sentence so bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
};
})
.x; // the .something needs to be here
}
The produces error is error[internal]: left behind trailing whitespace
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
ytmimi commentedon Aug 10, 2022
Thanks for the report.
Stripping back the example to just the following:
when we run rustfmt the line comment is changed into a block comment, but it isn't wrapped so it stays really long:
Then because we're dealing with a chain e.g.
g().x
, we hit the same issues that's causing #3863, and we don't reformat the any part of the chain, which means we leave the trailing whitespace. which is causing the warning that you're seeing.ytmimi commentedon Aug 10, 2022
But I can also confirm that with the original example using
wrap_comment=false
the trailing whitespace is removed, and withwrap_comments=true
the trailing whitespace remains after formatting. Interesting 🤔arifd commentedon Aug 28, 2022
ytmimi commentedon Aug 28, 2022
arifd commentedon Aug 28, 2022
Okay, thanks. created: #5521