diff --git a/src/comment.rs b/src/comment.rs index 7d7f56f54a5e..492b03c045a3 100644 --- a/src/comment.rs +++ b/src/comment.rs @@ -1321,6 +1321,11 @@ impl<'a> Iterator for LineClasses<'a> { } } + // Workaround for CRLF newline. + if line.ends_with('\r') { + line.pop(); + } + Some((self.kind, line)) } } diff --git a/tests/source/issue-3265.rs b/tests/source/issue-3265.rs new file mode 100644 index 000000000000..e927cf2be466 --- /dev/null +++ b/tests/source/issue-3265.rs @@ -0,0 +1,14 @@ +// rustfmt-newline_style: Windows +#[cfg(test)] +mod test { + summary_test! { + tokenize_recipe_interpolation_eol, + "foo: # some comment + {{hello}} +", + "foo: \ + {{hello}} \ +{{ahah}}", + "N:#$>^{N}$<.", + } +} diff --git a/tests/target/issue-3265.rs b/tests/target/issue-3265.rs new file mode 100644 index 000000000000..7db1dbd8b732 --- /dev/null +++ b/tests/target/issue-3265.rs @@ -0,0 +1,14 @@ +// rustfmt-newline_style: Windows +#[cfg(test)] +mod test { + summary_test! { + tokenize_recipe_interpolation_eol, + "foo: # some comment + {{hello}} +", + "foo: \ + {{hello}} \ + {{ahah}}", + "N:#$>^{N}$<.", + } +}