-
Notifications
You must be signed in to change notification settings - Fork 925
file-lines changes whitespace outside of given range #5136
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
@rustbot label: +bug +only-with-option |
Error: The feature Please let |
@not-my-profile thank you for submitting the issue. I've done a little work to look into this. if you run
In the example you provided I see that you're using
Can you give that a shot and see if it helps? Also, is this an issue when you're not using Without looking too deeply into the code I'm assuming that by not including any files in the file-lines list rustfmt just assumes that it needs to reformat everything. |
I actually thought I had a vague memory of that being the case, but the help text also directly contradicts that fact. That needs to be rectified one way or the other, and probably worth checking to see if that was something that was already sorted on the other branch sometime last year |
It has nothing to do with stdin. All of these issues can be observed when specifying files with the described syntax and providing files via paths. |
@not-my-profile, I finally had some time to dig into this. I don't have answers for each of the points you brought up, but I can at least explain a few of them:
The Lines 180 to 198 in 8984438
I was initially tempted to look into As an aside, from my initial investigation
That's because we're always appending a newline line (also in Lines 207 to 209 in 8984438
I haven't looked at this at all, but I assume this could be fixed by having ast::Attribute::rewrite pass span information to rewrite_doc_comment, so that we could use
I'm haven't looked into this one either. It might have something to do with the comment being placed after the last ast node, but it's totally possible that it's an issue that would affect all comments. You mentioned that it only happened in certain situations. Do you have any examples where leading whitespace before a comment is preserved? |
Thanks for looking into this!
Yes, interestingly adding a newline results in the leading whitespace to be preserved:
|
Note that:
Why this is a problem
file-lines is meant to restrict the reformatting to specific sets of lines. Whitespace changes elsewhere are therefore undesirable.
#3397
The text was updated successfully, but these errors were encountered: