1 #![feature(tool_lints)]
3 #![warn(clippy::explicit_write)]
6 fn stdout() -> String {
10 fn stderr() -> String {
18 write!(std::io::stdout(), "test").unwrap();
19 write!(std::io::stderr(), "test").unwrap();
20 writeln!(std::io::stdout(), "test").unwrap();
21 writeln!(std::io::stderr(), "test").unwrap();
22 std::io::stdout().write_fmt(format_args!("test")).unwrap();
23 std::io::stderr().write_fmt(format_args!("test")).unwrap();
25 // these should not warn, different destination
28 let mut s = String::new();
29 write!(s, "test").unwrap();
30 write!(s, "test").unwrap();
31 writeln!(s, "test").unwrap();
32 writeln!(s, "test").unwrap();
33 s.write_fmt(format_args!("test")).unwrap();
34 s.write_fmt(format_args!("test")).unwrap();
35 write!(stdout(), "test").unwrap();
36 write!(stderr(), "test").unwrap();
37 writeln!(stdout(), "test").unwrap();
38 writeln!(stderr(), "test").unwrap();
39 stdout().write_fmt(format_args!("test")).unwrap();
40 stderr().write_fmt(format_args!("test")).unwrap();
42 // these should not warn, no unwrap
45 std::io::stdout().write_fmt(format_args!("test")).expect("no stdout");
46 std::io::stderr().write_fmt(format_args!("test")).expect("no stderr");