Description
The json emit mode currently always appends unix style line endings to the end of the output snippets (#4262 and #4259) .
It may not be possible to provide both the original and expected trailing line endings given our current solution for building the diff between original and expected formatting. rustfmt currently leverages the diff crate which results in the dropping of the trailing newline information (Refs #3850 (comment))
We could technically determine the correct newline style to apply for the expected formatting even with the current make_diff
approach, perhaps by leveraging some of the newline functions like effective_newline_style
. However, the challenges with original contents would pose problems for a scenario where the only changes rustfmt would make are newline style conversions.
rustfmt/src/formatting/newline_style.rs
Lines 26 to 36 in e208a39