-
Notifications
You must be signed in to change notification settings - Fork 925
#[cfg(debug_assertions)]
on expression causing odd formatting
#5873
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
Thank you for another report! |
I think the issue originates with how the expression is parsed. #[cfg(debug_assertions)]
aaaaa * bbbb; is parsed such that the attribute is only applied to
If you wrap the expression in parentheses, it formats as expected: #[cfg(debug_assertions)]
(aaaaa * bbbb); and this is parsed as
In the first code snippet, we end up at the following code because of the multiplication: I don't know if it is the intended behavior for the parser to only apply the attribute to the first part of the expression or if it's a bug. |
@GambitingMan thank you for taking the time to look into this! If this is a parsing issue, then it'll be best to handle this upstream in the compiler. |
I'm a bit reluctant to consider it a parsing bug (in the sense that it applies it to the wrong node), there's ambiguity here (what is |
This code:
Is formatted into this:
Any line shorter than that (17 characters) is formatted correctly. Not entirely sure what's happening here.
Maybe related: #5871, but not sure.
The text was updated successfully, but these errors were encountered: