fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

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