Closed
Description
For some reason, rustfmt arbitrarily decides to move the comment around in the following snippet:
fn main() {
if true { // explanation.
println!("hello");
}
}
(I am saying "arbitrarily" as this page has no explanation for why this happens)
This becomes:
fn main() {
if true {
// explanation.
println!("hello");
}
}
This is bad for 2 reasons:
- Why even move the comment? Having the explanation for the conditional on the same line as the conditional is perfectly fine, very readable and can help save some vertical space.
- If rustfmt for some reason must move the comment, it should be moved up. The comment was explaining the
if true
, and a comment explaining something should not come after the thing already happened! Currently, rustfmt actively degrades the quality of such comments. The reformatted code looks like the comment is explaining theprintln!
.
I am very worried now how many such comments that were in the compiler are wrong / confusing now because of this. :/