]> git.lizzy.rs Git - rust.git/blobdiff - tests/ui/write_with_newline.rs
Auto merge of #68717 - petrochenkov:stabexpat, r=varkor
[rust.git] / tests / ui / write_with_newline.rs
index 5d8543e578dee5ecaf6c9459d6a94d49a3ded751..93afd73d1114d257998089f1c683bfa090c06458 100644 (file)
@@ -1,11 +1,5 @@
-// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
+// FIXME: Ideally these suggestions would be fixed via rustfix. Blocked by rust-lang/rust#53934
+// // run-rustfix
 
 #![allow(clippy::write_literal)]
 #![warn(clippy::write_with_newline)]
@@ -38,6 +32,27 @@ fn main() {
 
     // Escaping
     write!(&mut v, "\\n"); // #3514
-    write!(&mut v, "\\\n");
+    write!(&mut v, "\\\n"); // should fail
     write!(&mut v, "\\\\n");
+
+    // Raw strings
+    write!(&mut v, r"\n"); // #3778
+
+    // Literal newlines should also fail
+    write!(
+        &mut v,
+        "
+"
+    );
+    write!(
+        &mut v,
+        r"
+"
+    );
+
+    // Don't warn on CRLF (#4208)
+    write!(&mut v, "\r\n");
+    write!(&mut v, "foo\r\n");
+    write!(&mut v, "\\r\n"); //~ ERROR
+    write!(&mut v, "foo\rbar\n");
 }