2 #![allow(unused_imports)]
3 #![warn(clippy::explicit_write)]
5 fn stdout() -> String {
9 fn stderr() -> String {
17 write!(std::io::stdout(), "test").unwrap();
18 write!(std::io::stderr(), "test").unwrap();
19 writeln!(std::io::stdout(), "test").unwrap();
20 writeln!(std::io::stderr(), "test").unwrap();
21 std::io::stdout().write_fmt(format_args!("test")).unwrap();
22 std::io::stderr().write_fmt(format_args!("test")).unwrap();
25 writeln!(std::io::stdout(), "test\ntest").unwrap();
26 writeln!(std::io::stderr(), "test\ntest").unwrap();
28 // these should not warn, different destination
31 let mut s = String::new();
32 write!(s, "test").unwrap();
33 write!(s, "test").unwrap();
34 writeln!(s, "test").unwrap();
35 writeln!(s, "test").unwrap();
36 s.write_fmt(format_args!("test")).unwrap();
37 s.write_fmt(format_args!("test")).unwrap();
38 write!(stdout(), "test").unwrap();
39 write!(stderr(), "test").unwrap();
40 writeln!(stdout(), "test").unwrap();
41 writeln!(stderr(), "test").unwrap();
42 stdout().write_fmt(format_args!("test")).unwrap();
43 stderr().write_fmt(format_args!("test")).unwrap();
45 // these should not warn, no unwrap
48 std::io::stdout().write_fmt(format_args!("test")).expect("no stdout");
49 std::io::stderr().write_fmt(format_args!("test")).expect("no stderr");