-
Notifications
You must be signed in to change notification settings - Fork 915
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
Formatting does not work with match arm having mixed OR clauses and comments #6491
Comments
When you try formatting this with
rustfmt isn't expecting to find comments within the OR pattern and would remove them if the code was formatted. I'm not sure how simple this would be to solve. We usually use It might be as simple as defining Lines 90 to 117 in c6c8159
It's also likely that any change here would need to be gated. If you're interested in working on this one you can comment |
@rustbot claim |
I've played around with this in a few ways. The parser treats the first comment as a standalone comment, and the subsequent ones as "post-comments" for the preceding pattern. Using fn main() {
let foo = Foo::A;
match foo {
// Here is a comment
Foo::A // And another one
| Foo::B // Hey look! There's another one
| Foo::C // That's a lot of comments
| Foo::D => {}
}
} This breaks pretty badly when there is a multi-line comment, or just multiple single line comments. Tbh, I'm not even sure what the expected formatting would be, it can vary based on the placement of the |
@rustbot release-assignment |
Related to #6060 and #6044. For the below snippet, rustfmt does nothing at all:
If someone more knowledgeable about rustfmt internals can please confirm that this is a solvable bug, I'd be happy to contribute the fix.
The text was updated successfully, but these errors were encountered: