about summary refs log tree commit diff
path: root/tests/ui/writeln_empty_string.fixed
diff options
context:
space:
mode:
authorPhilipp Hansch <dev@phansch.net>2019-01-04 11:22:38 +0100
committerPhilipp Hansch <dev@phansch.net>2019-01-04 11:22:38 +0100
commit319f18e54dc84cc413df18d110a38ea340a91c86 (patch)
tree9629d4c8994021044c80e60b82a55b7f50fd436c /tests/ui/writeln_empty_string.fixed
parent756b32e1e2ad474097f8d3e510b319dd5023297d (diff)
downloadrust-319f18e54dc84cc413df18d110a38ea340a91c86.tar.gz
rust-319f18e54dc84cc413df18d110a38ea340a91c86.zip
Add run-rustfix where it already passes
Diffstat (limited to 'tests/ui/writeln_empty_string.fixed')
-rw-r--r--tests/ui/writeln_empty_string.fixed29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/ui/writeln_empty_string.fixed b/tests/ui/writeln_empty_string.fixed
new file mode 100644
index 00000000000..68b8185083d
--- /dev/null
+++ b/tests/ui/writeln_empty_string.fixed
@@ -0,0 +1,29 @@
+// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// run-rustfix
+
+#![allow(unused_must_use)]
+#![warn(clippy::writeln_empty_string)]
+use std::io::Write;
+
+fn main() {
+    let mut v = Vec::new();
+
+    // These should fail
+    writeln!(&mut v);
+
+    let mut suggestion = Vec::new();
+    writeln!(&mut suggestion);
+
+    // These should be fine
+    writeln!(&mut v);
+    writeln!(&mut v, " ");
+    write!(&mut v, "");
+}