fork/rust
git clone https://git.julia.blue/fork/rust
3bcad65fbf6
master
1#![allow(clippy::print_literal)] 2#![warn(clippy::print_with_newline)] 3 4fn main() { 5 eprintln!("Hello"); 6 //~^ ERROR: using `eprint!()` with a format string that ends in a single newline 7 //~| NOTE: `-D clippy::print-with-newline` implied by `-D warnings` 8 eprintln!("Hello {}", "world"); 9 //~^ ERROR: using `eprint!()` with a format string that ends in a single newline 10 eprintln!("Hello {} {}", "world", "#2"); 11 //~^ ERROR: using `eprint!()` with a format string that ends in a single newline 12 eprintln!("{}", 1265); 13 //~^ ERROR: using `eprint!()` with a format string that ends in a single newline 14 eprintln!(); 15 //~^ ERROR: using `eprint!()` with a format string that ends in a single newline 16 17 // these are all fine 18 eprint!(""); 19 eprint!("Hello"); 20 eprintln!("Hello"); 21 eprintln!("Hello\n"); 22 eprintln!("Hello {}\n", "world"); 23 eprint!("Issue\n{}", 1265); 24 eprint!("{}", 1265); 25 eprint!("\n{}", 1275); 26 eprint!("\n\n"); 27 eprint!("like eof\n\n"); 28 eprint!("Hello {} {}\n\n", "world", "#2"); 29 // #3126 30 eprintln!("\ndon't\nwarn\nfor\nmultiple\nnewlines\n"); 31 // #3126 32 eprintln!("\nbla\n\n"); 33 34 // Escaping 35 // #3514 36 eprint!("\\n"); 37 eprintln!("\\"); 38 //~^ ERROR: using `eprint!()` with a format string that ends in a single newline 39 eprint!("\\\\n"); 40 41 // Raw strings 42 // #3778 43 eprint!(r"\n"); 44 45 // Literal newlines should also fail 46 eprintln!( 47 //~^ ERROR: using `eprint!()` with a format string that ends in a single newline 48 49 ); 50 eprintln!( 51 //~^ ERROR: using `eprint!()` with a format string that ends in a single newline 52 53 ); 54 55 // Don't warn on CRLF (#4208) 56 eprint!("\r\n"); 57 eprint!("foo\r\n"); 58 eprintln!("\\r"); 59 //~^ ERROR: using `eprint!()` with a format string that ends in a single newline 60 eprint!("foo\rbar\n"); 61 62 // Ignore expanded format strings 63 macro_rules! newline { 64 () => { 65 "\n" 66 }; 67 } 68 eprint!(newline!()); 69}