-
Notifications
You must be signed in to change notification settings - Fork 876
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
JSON output for removing blank lines is wrong #4259
Comments
Here's another case that causes issues. It seems like there should be newlines that get stripped.
I think it's trying to reformat it alphabetically, like
But what you actually get is
I think both instances of |
Thanks for the report @Timmmm, and for giving the rustfmt 2.0-rc a test drive!
Yup, the default behavior is to reorder mods alphabetically, and this can controlled by the reorder_modules configuration option.
Not exactly. The fact that there's mismatches in the output is indicative that something does need to be changed, it's just ambiguous what those changes are. I feel the question is really about how newline changes should be represented in the output, whether implicit/assumed given the line numbers, or explicitly. It's clearly not explicit right now, and the scenarios you've shared here raise some good points about why IMO something should change. In addition to the removal of newline chars, it'd also be tricky to know from the json output when a newline is inserted, especially since rustfmt could be emitting different newline styles depending on the config. The json emit mode (which is also used with If anyone's interested and willing to try updating this that would be fantastic and we'd be happy to offer assistance! The mismatch specification logic for the json emit mode can be found here: Lines 57 to 102 in cf1f0cf
It may also be helpful to cross reference the function that generates the visual output found with the |
This changes the JSON output to be more consistent about where newlines are included. Previously it only included them between lines in a multiline diff. That meant single line changes were treated a bit weirdly. This changes it to append a newline to every line. When feeding the results into `arc lint` this behaves correctly. I have only done limited testing though, in particular there's a possibility it might not work with files with `\r\n` endings (though that would have been the case before too). Fixes rust-lang#4259
This changes the JSON output to be more consistent about where newlines are included. Previously it only included them between lines in a multiline diff. That meant single line changes were treated a bit weirdly. This changes it to append a newline to every line. When feeding the results into `arc lint` this behaves correctly. I have only done limited testing though, in particular there's a possibility it might not work with files with `\r\n` endings (though that would have been the case before too). Fixes rust-lang#4259
Thanks for the hint! Turns out the fix was quite easy. :-) |
* Fix newlines in JSON output This changes the JSON output to be more consistent about where newlines are included. Previously it only included them between lines in a multiline diff. That meant single line changes were treated a bit weirdly. This changes it to append a newline to every line. When feeding the results into `arc lint` this behaves correctly. I have only done limited testing though, in particular there's a possibility it might not work with files with `\r\n` endings (though that would have been the case before too). Fixes #4259 * Update tests
* Fix newlines in JSON output This changes the JSON output to be more consistent about where newlines are included. Previously it only included them between lines in a multiline diff. That meant single line changes were treated a bit weirdly. This changes it to append a newline to every line. When feeding the results into `arc lint` this behaves correctly. I have only done limited testing though, in particular there's a possibility it might not work with files with `\r\n` endings (though that would have been the case before too). Fixes rust-lang#4259 * Update tests # Conflicts: # tests/writemode/target/output.json
* Fix newlines in JSON output This changes the JSON output to be more consistent about where newlines are included. Previously it only included them between lines in a multiline diff. That meant single line changes were treated a bit weirdly. This changes it to append a newline to every line. When feeding the results into `arc lint` this behaves correctly. I have only done limited testing though, in particular there's a possibility it might not work with files with `\r\n` endings (though that would have been the case before too). Fixes #4259 * Update tests # Conflicts: # tests/writemode/target/output.json
Rustfmt version:
rustfmt 2.0.0-rc.2-nightly (e9b039ea 2020-06-03)
If Rustfmt decides to remove a blank line, the JSON output says that actually nothing needs to change. Trivial repro:
It seems fine at removing newlines in other cases:
So I think the output should be something like this:
The text was updated successfully, but these errors were encountered: