-
Notifications
You must be signed in to change notification settings - Fork 898
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 a macro that generates a struct with a field with a multiline attribute adds indentation forever #5489
Comments
Believe this is just another case like #4609 and various others |
Perhaps, but PR #5473 from @davidBar-On does not appear to prevent this case. |
Perhaps I should've elaborated, but it was deliberate that I didn't close this issue/mark as a duplicate. The behavior you're seeing is based on a chain of two bugs/gaps. The first is a more general class where rustfmt's attempts to convert the macro contents into something it can format fails, and there's various, unrelated macro scenarios that can trigger this. This failure is actually not terribly impactful (it just results in rustfmt deciding to leave the mac alone). However, that failure then triggers the second bug which is the one that causes the runaway indentation. The PR you've referenced is an attempt to fix a specific type of the first class (which is different than the cause of your snippet, hence the non-effect), but doesn't attempt to address the second. Ideally we'd fix this second one, but it's proven to be rather gnarly. Essentially, your issue could be addressed in one of two ways:
|
A problem with this approach is that the format error is not propagated to the code that handles the macro formatting. In PR #4629 I tried to fix that, so that the format error will be propagated, but it was decided that it is better to resolve each specific cause than taking this approach. |
The root cause of the problem is here: Line 348 in ea017d7
This is not a macro only issue. The same problem happens if a It seems that to resolve the issue |
On a second though, a better solution is that Can someone help with where such change can be discussed or suggested? |
Submitted PR #5518 with a suggested fix, although a better approach for the fix is probably enhancing |
The arguments of the
clap
attribute will be indented for every call tocargo fmt
. For example...This occurs with:
rustfmt 1.4.38-stable (e092d0b6 2022-07-16)
rustfmt 1.5.1-nightly (f6f9d5e7 2022-08-04)
The text was updated successfully, but these errors were encountered: