1 // Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution.
4 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7 // option. This file may not be copied, modified, or distributed
8 // except according to those terms.
10 #![allow(clippy::write_literal)]
11 #![warn(clippy::write_with_newline)]
16 let mut v = Vec::new();
19 write!(&mut v, "Hello\n");
20 write!(&mut v, "Hello {}\n", "world");
21 write!(&mut v, "Hello {} {}\n", "world", "#2");
22 write!(&mut v, "{}\n", 1265);
24 // These should be fine
26 write!(&mut v, "Hello");
27 writeln!(&mut v, "Hello");
28 writeln!(&mut v, "Hello\n");
29 writeln!(&mut v, "Hello {}\n", "world");
30 write!(&mut v, "Issue\n{}", 1265);
31 write!(&mut v, "{}", 1265);
32 write!(&mut v, "\n{}", 1275);
33 write!(&mut v, "\n\n");
34 write!(&mut v, "like eof\n\n");
35 write!(&mut v, "Hello {} {}\n\n", "world", "#2");
36 writeln!(&mut v, "\ndon't\nwarn\nfor\nmultiple\nnewlines\n"); // #3126
37 writeln!(&mut v, "\nbla\n\n"); // #3126
40 write!(&mut v, "\\n"); // #3514
41 write!(&mut v, "\\\n");
42 write!(&mut v, "\\\\n");