]> git.lizzy.rs Git - rust.git/blob - tests/ui/print_with_newline.rs
iterate List by value
[rust.git] / tests / ui / print_with_newline.rs
1 // FIXME: Ideally these suggestions would be fixed via rustfix. Blocked by rust-lang/rust#53934
2 // // run-rustfix
3
4 #![allow(clippy::print_literal)]
5 #![warn(clippy::print_with_newline)]
6
7 fn main() {
8     print!("Hello\n");
9     print!("Hello {}\n", "world");
10     print!("Hello {} {}\n", "world", "#2");
11     print!("{}\n", 1265);
12
13     // these are all fine
14     print!("");
15     print!("Hello");
16     println!("Hello");
17     println!("Hello\n");
18     println!("Hello {}\n", "world");
19     print!("Issue\n{}", 1265);
20     print!("{}", 1265);
21     print!("\n{}", 1275);
22     print!("\n\n");
23     print!("like eof\n\n");
24     print!("Hello {} {}\n\n", "world", "#2");
25     println!("\ndon't\nwarn\nfor\nmultiple\nnewlines\n"); // #3126
26     println!("\nbla\n\n"); // #3126
27
28     // Escaping
29     print!("\\n"); // #3514
30     print!("\\\n"); // should fail
31     print!("\\\\n");
32
33     // Raw strings
34     print!(r"\n"); // #3778
35
36     // Literal newlines should also fail
37     print!(
38         "
39 "
40     );
41     print!(
42         r"
43 "
44     );
45
46     // Don't warn on CRLF (#4208)
47     print!("\r\n");
48     print!("foo\r\n");
49     print!("\\r\n"); //~ ERROR
50     print!("foo\rbar\n") // ~ ERROR
51 }