-
Notifications
You must be signed in to change notification settings - Fork 930
Fix handling of code that is annotated with rustfmt::skip. #3113
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
Conversation
Hmm, actually I am not sure if rustfmt is allowed to change the indentation of items under |
@topecongiro at first I thought keeping the layout was enough but indeed I realise now there can be situations where even indenting the code with the rest would be unwanted. Maybe a better fix would be not to change the indentation at all:
what do you think ? |
@scampi, I agree. If something is marked as |
@topecongiro @otavio thanks for your input. Just proposing the changes now to know if that is a good direction. The solution I have found is to keep track of skipped lines which allows caller code to act on those accordingly. Those lines are stored as a list of ranges. In addition to skipped lines, this list could also be used to keep track of lines that could not be formatted and where the original lines were used instead, e.g., the issue #3045. |
I think we should not change the indentation at all, since it is possible to make the lines overrun the max width. The user can change the indentation manually and then we'll preserve it. |
I'm unclear now - is this intended to fit |
Taking the shuffle_done! macro definition as example, the method That The problem occurs at this point: the following piece is indenting the macro's body. Since the original (skipped) lines were returned, the |
A rustfmt::skip'ed block is indented although original lines are returned. In order to resolve this, the leading whitespaces are trimmed on each line while retaining the layout; this leaves the skipped code to be indented as necessary by the caller.
… indentation which would cause code right-shifting
Thank you! |
@scampi My apologies for the late reply. Thank you for your work and updates! |
no worries @topecongiro |
A rustfmt::skip'ed block is indented although original lines are
returned. In order to resolve this, the leading whitespaces are trimmed
on each line while retaining the layout; this leaves the skipped code
to be indented as necessary by the caller.
Close #3105