We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
I write this code:
struct Abc([u8; // five 5 + // ten 10 + // thirteen 13 ]);
rustfmt formats this to:
struct Abc( [u8; 5 + // ten 10 + // thirteen 13], );
It has lost the // five comment. The remainder of the formatting is not great.
// five
playground
version:
rustfmt 1.8.0-stable (90b35a6239 2024-11-26)
A workaround is to surround the expression in const { .. }
const { .. }
edit: although a comment before the const is still removed:
const
struct Abc( [u8; // blorp const { // five 5 + // ten 10 + // thirteen 13 }], );
is formatted to:
struct Abc( [u8; const { // five 5 + // ten 10 + // thirteen 13 }], );
Thanks for the report. This is related to #5297, except the error occurs in expression rewriting:
rustfmt/src/expr.rs
Lines 284 to 291 in a43eef1
Activity
[-]rustfmt deletes comments in array length[/-][+]rustfmt deletes comment at start of array length expression[/+]ctz commentedon Jan 2, 2025
A workaround is to surround the expression in
const { .. }
edit: although a comment before the
const
is still removed:is formatted to:
ytmimi commentedon Jan 2, 2025
Thanks for the report. This is related to #5297, except the error occurs in expression rewriting:
rustfmt/src/expr.rs
Lines 284 to 291 in a43eef1