about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/comment.rs5
-rw-r--r--tests/source/issue-3265.rs14
-rw-r--r--tests/target/issue-3265.rs14
3 files changed, 33 insertions, 0 deletions
diff --git a/src/comment.rs b/src/comment.rs
index 7d7f56f54a5..492b03c045a 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 00000000000..e927cf2be46
--- /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 00000000000..7db1dbd8b73
--- /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}$<.",
+      }
+}