]>
git.proxmox.com Git - rustc.git/blob - src/tools/clippy/tests/ui/explicit_write.rs
1 #![warn(explicit_write)]
4 fn stdout() -> String
{
8 fn stderr() -> String
{
16 write
!(std
::io
::stdout(), "test").unwrap();
17 write
!(std
::io
::stderr(), "test").unwrap();
18 writeln
!(std
::io
::stdout(), "test").unwrap();
19 writeln
!(std
::io
::stderr(), "test").unwrap();
20 std
::io
::stdout().write_fmt(format_args
!("test")).unwrap();
21 std
::io
::stderr().write_fmt(format_args
!("test")).unwrap();
23 // these should not warn, different destination
26 let mut s
= String
::new();
27 write
!(s
, "test").unwrap();
28 write
!(s
, "test").unwrap();
29 writeln
!(s
, "test").unwrap();
30 writeln
!(s
, "test").unwrap();
31 s
.write_fmt(format_args
!("test")).unwrap();
32 s
.write_fmt(format_args
!("test")).unwrap();
33 write
!(stdout(), "test").unwrap();
34 write
!(stderr(), "test").unwrap();
35 writeln
!(stdout(), "test").unwrap();
36 writeln
!(stderr(), "test").unwrap();
37 stdout().write_fmt(format_args
!("test")).unwrap();
38 stderr().write_fmt(format_args
!("test")).unwrap();
40 // these should not warn, no unwrap
43 std
::io
::stdout().write_fmt(format_args
!("test")).expect("no stdout");
44 std
::io
::stderr().write_fmt(format_args
!("test")).expect("no stderr");