Skip to content

Instantly share code, notes, and snippets.

@bookshelfdave
Created September 13, 2019 18:22
Show Gist options
  • Save bookshelfdave/bd8491a67e735bed880d03c91ae99972 to your computer and use it in GitHub Desktop.
Save bookshelfdave/bd8491a67e735bed880d03c91ae99972 to your computer and use it in GitHub Desktop.
diff --git a/clippy_lints/src/write.rs b/clippy_lints/src/write.rs
index 7d72a21a..83cf4c01 100644
--- a/clippy_lints/src/write.rs
+++ b/clippy_lints/src/write.rs
@@ -440,12 +440,15 @@ fn check_tts<'a>(cx: &EarlyContext<'a>, tts: &TokenStream, is_write: bool) -> (O
}
}
-/// Checks if the format string constains a single newline that terminates it.
+/// TODO: update these docs
+/// Checks if the format string contains a single newline that terminates it.
///
/// Literal and escaped newlines are both checked (only literal for raw strings).
fn check_newlines(fmt_str: &FmtStr) -> bool {
let s = &fmt_str.contents;
-
+ if s.ends_with("\\r\\n") {
+ return false;
+ }
if s.ends_with('\n') {
return true;
} else if let StrStyle::Raw(_) = fmt_str.style {
diff --git a/tests/ui/write_with_newline.rs b/tests/ui/write_with_newline.rs
index f0b13a69..dd8c7bf9 100644
--- a/tests/ui/write_with_newline.rs
+++ b/tests/ui/write_with_newline.rs
@@ -49,4 +49,7 @@ fn main() {
r"
"
);
+
+ // /r stuff
+ write!(&mut v, "\nfoobar123\r\n");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment