You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Notice how there are three spaces between the trailing comma and the comment 2 in the incorrect example.
Examples can be reproduced on the Rust Playground, which uses rustfmt 1.6.0-nighty (2023-07-10 8ca44ef), as well as with rust-analyzer v0.3.1583 VS Code extension.
The text was updated successfully, but these errors were encountered:
rustfmt is trying to align the comments. If you were to manually format 0x0, // comment 1 and move it to the next line you'll see that. Here's what it looks like:
let example_incorrect = [0,0x0,// comment 10,// comment 2];
0 and 0x0, are small enough that rustfmt uses a compressed formatting style when outputting the array. however it incorrectly tries to align comments in this case, and it would probably be best not to align comments if we're not using a vertical layout.
To further observe and highlight the comment alignment you can run rustfmt and set short_array_element_width_threshold=0:
When inserting line comments in an array literal,
rustfmt
sometimes insert unnecessary empty space.Simplest example:
Notice how there are three spaces between the trailing comma and the comment 2 in the incorrect example.
Examples can be reproduced on the Rust Playground, which uses
rustfmt 1.6.0-nighty (2023-07-10 8ca44ef)
, as well as withrust-analyzer v0.3.1583
VS Code extension.The text was updated successfully, but these errors were encountered: