From c23a457e72abe608715ac76f076f47dc42af07a5 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 30 May 2024 20:31:44 +0200 Subject: Merging upstream version 1.74.1+dfsg1. Signed-off-by: Daniel Baumann --- src/tools/clippy/tests/ui/eprint_with_newline.rs | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'src/tools/clippy/tests/ui/eprint_with_newline.rs') diff --git a/src/tools/clippy/tests/ui/eprint_with_newline.rs b/src/tools/clippy/tests/ui/eprint_with_newline.rs index 8389806c8..5b1140564 100644 --- a/src/tools/clippy/tests/ui/eprint_with_newline.rs +++ b/src/tools/clippy/tests/ui/eprint_with_newline.rs @@ -3,10 +3,16 @@ fn main() { eprint!("Hello\n"); + //~^ ERROR: using `eprint!()` with a format string that ends in a single newline + //~| NOTE: `-D clippy::print-with-newline` implied by `-D warnings` eprint!("Hello {}\n", "world"); + //~^ ERROR: using `eprint!()` with a format string that ends in a single newline eprint!("Hello {} {}\n", "world", "#2"); + //~^ ERROR: using `eprint!()` with a format string that ends in a single newline eprint!("{}\n", 1265); + //~^ ERROR: using `eprint!()` with a format string that ends in a single newline eprint!("\n"); + //~^ ERROR: using `eprint!()` with a format string that ends in a single newline // these are all fine eprint!(""); @@ -20,23 +26,30 @@ fn main() { eprint!("\n\n"); eprint!("like eof\n\n"); eprint!("Hello {} {}\n\n", "world", "#2"); - eprintln!("\ndon't\nwarn\nfor\nmultiple\nnewlines\n"); // #3126 - eprintln!("\nbla\n\n"); // #3126 + // #3126 + eprintln!("\ndon't\nwarn\nfor\nmultiple\nnewlines\n"); + // #3126 + eprintln!("\nbla\n\n"); // Escaping - eprint!("\\n"); // #3514 - eprint!("\\\n"); // should fail + // #3514 + eprint!("\\n"); + eprint!("\\\n"); + //~^ ERROR: using `eprint!()` with a format string that ends in a single newline eprint!("\\\\n"); // Raw strings - eprint!(r"\n"); // #3778 + // #3778 + eprint!(r"\n"); // Literal newlines should also fail eprint!( + //~^ ERROR: using `eprint!()` with a format string that ends in a single newline " " ); eprint!( + //~^ ERROR: using `eprint!()` with a format string that ends in a single newline r" " ); @@ -45,6 +58,7 @@ fn main() { eprint!("\r\n"); eprint!("foo\r\n"); eprint!("\\r\n"); + //~^ ERROR: using `eprint!()` with a format string that ends in a single newline eprint!("foo\rbar\n"); // Ignore expanded format strings -- cgit v1.2.3