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
fn f() {
const S: usize = 4 + // id
1 + // direction
5; // something
}
I've been trying to explain where my constant comes from with comments, but that seems to break the way this is formatted. I was expecting something more like what clang format does:
void f() {
constexpr auto S = 4 + // id
1 + // direction
5; // something
}
I see now that there's the following error printed when I ask for it, but I don't feel like it's justified. I just want some alignment for the expressions to look a little nicer. I realize that I can put the comment on the next line, but it felt more informative and less easy to forget to update the way I did it.
error[internal]: not formatted because a comment would be lost
--> \\?\D:\repos\dune\x.rs:2
|
2 | const S: usize = 4 + // id
|
= note: set `error_on_unformatted = false` to suppress the warning against comments or string literals
The text was updated successfully, but these errors were encountered:
Thanks for reaching out, but going to close this as a duplicate of #3591 and #3167. The issue is that we don't handle comments in binary expressions. rustfmt wants to rewrite your code as const S: usize = 4 + 1 + 5;, but doing so would remove the comment and therefore rustfmt leaves the code unformatted.
I've been trying to explain where my constant comes from with comments, but that seems to break the way this is formatted. I was expecting something more like what clang format does:
I see now that there's the following error printed when I ask for it, but I don't feel like it's justified. I just want some alignment for the expressions to look a little nicer. I realize that I can put the comment on the next line, but it felt more informative and less easy to forget to update the way I did it.
The text was updated successfully, but these errors were encountered: