about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--tests/ui/print_with_newline.rs8
-rw-r--r--tests/ui/print_with_newline.stderr8
-rw-r--r--tests/ui/write_with_newline.rs2
-rw-r--r--tests/ui/write_with_newline.stderr2
4 files changed, 17 insertions, 3 deletions
diff --git a/tests/ui/print_with_newline.rs b/tests/ui/print_with_newline.rs
index 991cd7311e5..9df4b9052de 100644
--- a/tests/ui/print_with_newline.rs
+++ b/tests/ui/print_with_newline.rs
@@ -21,4 +21,12 @@ fn main() {
     print!("Hello {} {}\n\n", "world", "#2");
     println!("\ndon't\nwarn\nfor\nmultiple\nnewlines\n"); // #3126
     println!("\nbla\n\n"); // #3126
+
+    // Escaping
+    print!("\\n"); // #3514
+    print!("\\\n"); // should fail
+    print!("\\\\n");
+
+    // Raw strings
+    print!(r"\n"); // #3778
 }
diff --git a/tests/ui/print_with_newline.stderr b/tests/ui/print_with_newline.stderr
index a731212be87..1d89a16e090 100644
--- a/tests/ui/print_with_newline.stderr
+++ b/tests/ui/print_with_newline.stderr
@@ -24,5 +24,11 @@ error: using `print!()` with a format string that ends in a single newline, cons
 LL |     print!("{}/n", 1265);
    |     ^^^^^^^^^^^^^^^^^^^^
 
-error: aborting due to 4 previous errors
+error: using `print!()` with a format string that ends in a single newline, consider using `println!()` instead
+  --> $DIR/print_with_newline.rs:27:5
+   |
+LL |     print!("//n"); // should fail
+   |     ^^^^^^^^^^^^^^
+
+error: aborting due to 5 previous errors
 
diff --git a/tests/ui/write_with_newline.rs b/tests/ui/write_with_newline.rs
index 02e043f9233..3575dd6da80 100644
--- a/tests/ui/write_with_newline.rs
+++ b/tests/ui/write_with_newline.rs
@@ -29,7 +29,7 @@ fn main() {
 
     // Escaping
     write!(&mut v, "\\n"); // #3514
-    write!(&mut v, "\\\n");
+    write!(&mut v, "\\\n"); // should fail
     write!(&mut v, "\\\\n");
 
     // Raw strings
diff --git a/tests/ui/write_with_newline.stderr b/tests/ui/write_with_newline.stderr
index 1f4395c2621..b0761f3b081 100644
--- a/tests/ui/write_with_newline.stderr
+++ b/tests/ui/write_with_newline.stderr
@@ -27,7 +27,7 @@ LL |     write!(&mut v, "{}/n", 1265);
 error: using `write!()` with a format string that ends in a single newline, consider using `writeln!()` instead
   --> $DIR/write_with_newline.rs:32:5
    |
-LL |     write!(&mut v, "//n");
+LL |     write!(&mut v, "//n"); // should fail
    |     ^^^^^^^^^^^^^^^^^^^^^^
 
 error: aborting due to 5 previous errors