-
Notifications
You must be signed in to change notification settings - Fork 926
Block-align inside array behaves unexpectedly #5630
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@BenWiederhake thanks for reaching out. Are there other examples you can point to where multi-line comments between list items are properly aligned? My understanding is that we don't normally want to align these comments. You might get some relief by applying a fn main() {
some_func(
#[rustfmt::skip]
&[
// Let's say I have a bunch of numbers.
0, // For example, a short 0. But lots of comments are needed.
0x1234, // Or a slightly longer value.
0xFF, // Fun fact: My personal use-case is providing hand-written
// assembly, and not all directives translate to
// instructions (e.g. labels).
0x666, // Wouldn't it be nice if all comments were aligned?
0x42, // However, cargo-fmt strongly disagrees with that.
// Hence, this minimal reproducing example.
],
5, // Necessary, for some reason.
);
} Given that you're trying to write assembly is it not possible to use the |
Thanks! The I'm sad to hear that rustfmt doesn't want to align comments like that, but then I'll have to live with it. (Wontfix, if I understand you correctly.) The assembly is not any assembly that rustc could possibly handle, since it's for a different platform. Good idea, but doesn't apply here. EDIT: |
I found a corner-case where rustfmt changes the formatting in a way that really doesn't look good in my eyes.
Minimal reproducing example:
(I also provided this as a repository.)
The main point is the block of comments in the middle. Observe how all comments are aligned. In the particular use-case of handwritten assembly, this is very desirable: The assembly directives could go on the right, and aligning them makes them easier to read.
rustfmt changes it to this:
This shows that rustfmt does have some concept of aligning comments with each other. However, I see no pattern in this behavior, and frankly it doesn't seem very readable to me. Can this be fixed?
I found no mention of this in any other issue. There are some similar results, but they're all different issues:
Btw, except for this weird scenario, rustfmt has always guided me towards nicer, more easily readable code. Awesome, thank you! :)
The text was updated successfully, but these errors were encountered: