about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--tests/ui/cast_lossless_float.fixed26
-rw-r--r--tests/ui/cast_lossless_float.rs2
-rw-r--r--tests/ui/cast_lossless_float.stderr20
-rw-r--r--tests/ui/cast_lossless_integer.fixed34
-rw-r--r--tests/ui/cast_lossless_integer.rs2
-rw-r--r--tests/ui/cast_lossless_integer.stderr36
-rw-r--r--tests/ui/double_comparison.fixed39
-rw-r--r--tests/ui/double_comparison.rs2
-rw-r--r--tests/ui/double_comparison.stderr16
-rw-r--r--tests/ui/println_empty_string.fixed19
-rw-r--r--tests/ui/println_empty_string.rs2
-rw-r--r--tests/ui/println_empty_string.stderr4
-rw-r--r--tests/ui/ptr_offset_with_cast.fixed29
-rw-r--r--tests/ui/ptr_offset_with_cast.rs2
-rw-r--r--tests/ui/ptr_offset_with_cast.stderr4
-rw-r--r--tests/ui/single_char_pattern.fixed61
-rw-r--r--tests/ui/single_char_pattern.rs2
-rw-r--r--tests/ui/single_char_pattern.stderr40
-rw-r--r--tests/ui/string_extend.fixed41
-rw-r--r--tests/ui/string_extend.rs2
-rw-r--r--tests/ui/string_extend.stderr6
-rw-r--r--tests/ui/unreadable_literal.fixed29
-rw-r--r--tests/ui/unreadable_literal.rs2
-rw-r--r--tests/ui/unreadable_literal.stderr10
-rw-r--r--tests/ui/vec.fixed64
-rw-r--r--tests/ui/vec.rs2
-rw-r--r--tests/ui/vec.stderr12
-rw-r--r--tests/ui/writeln_empty_string.fixed29
-rw-r--r--tests/ui/writeln_empty_string.rs2
-rw-r--r--tests/ui/writeln_empty_string.stderr4
30 files changed, 467 insertions, 76 deletions
diff --git a/tests/ui/cast_lossless_float.fixed b/tests/ui/cast_lossless_float.fixed
new file mode 100644
index 00000000000..5f4e54eb565
--- /dev/null
+++ b/tests/ui/cast_lossless_float.fixed
@@ -0,0 +1,26 @@
+// 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
+
+#[warn(clippy::cast_lossless)]
+#[allow(clippy::no_effect, clippy::unnecessary_operation)]
+fn main() {
+    // Test clippy::cast_lossless with casts to floating-point types
+    f32::from(1i8);
+    f64::from(1i8);
+    f32::from(1u8);
+    f64::from(1u8);
+    f32::from(1i16);
+    f64::from(1i16);
+    f32::from(1u16);
+    f64::from(1u16);
+    f64::from(1i32);
+    f64::from(1u32);
+}
diff --git a/tests/ui/cast_lossless_float.rs b/tests/ui/cast_lossless_float.rs
index e52a756c003..b818010feb2 100644
--- a/tests/ui/cast_lossless_float.rs
+++ b/tests/ui/cast_lossless_float.rs
@@ -7,6 +7,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// run-rustfix
+
 #[warn(clippy::cast_lossless)]
 #[allow(clippy::no_effect, clippy::unnecessary_operation)]
 fn main() {
diff --git a/tests/ui/cast_lossless_float.stderr b/tests/ui/cast_lossless_float.stderr
index 2164315c35e..aa48bd4d1c7 100644
--- a/tests/ui/cast_lossless_float.stderr
+++ b/tests/ui/cast_lossless_float.stderr
@@ -1,5 +1,5 @@
 error: casting i8 to f32 may become silently lossy if types change
-  --> $DIR/cast_lossless_float.rs:14:5
+  --> $DIR/cast_lossless_float.rs:16:5
    |
 LL |     1i8 as f32;
    |     ^^^^^^^^^^ help: try: `f32::from(1i8)`
@@ -7,55 +7,55 @@ LL |     1i8 as f32;
    = note: `-D clippy::cast-lossless` implied by `-D warnings`
 
 error: casting i8 to f64 may become silently lossy if types change
-  --> $DIR/cast_lossless_float.rs:15:5
+  --> $DIR/cast_lossless_float.rs:17:5
    |
 LL |     1i8 as f64;
    |     ^^^^^^^^^^ help: try: `f64::from(1i8)`
 
 error: casting u8 to f32 may become silently lossy if types change
-  --> $DIR/cast_lossless_float.rs:16:5
+  --> $DIR/cast_lossless_float.rs:18:5
    |
 LL |     1u8 as f32;
    |     ^^^^^^^^^^ help: try: `f32::from(1u8)`
 
 error: casting u8 to f64 may become silently lossy if types change
-  --> $DIR/cast_lossless_float.rs:17:5
+  --> $DIR/cast_lossless_float.rs:19:5
    |
 LL |     1u8 as f64;
    |     ^^^^^^^^^^ help: try: `f64::from(1u8)`
 
 error: casting i16 to f32 may become silently lossy if types change
-  --> $DIR/cast_lossless_float.rs:18:5
+  --> $DIR/cast_lossless_float.rs:20:5
    |
 LL |     1i16 as f32;
    |     ^^^^^^^^^^^ help: try: `f32::from(1i16)`
 
 error: casting i16 to f64 may become silently lossy if types change
-  --> $DIR/cast_lossless_float.rs:19:5
+  --> $DIR/cast_lossless_float.rs:21:5
    |
 LL |     1i16 as f64;
    |     ^^^^^^^^^^^ help: try: `f64::from(1i16)`
 
 error: casting u16 to f32 may become silently lossy if types change
-  --> $DIR/cast_lossless_float.rs:20:5
+  --> $DIR/cast_lossless_float.rs:22:5
    |
 LL |     1u16 as f32;
    |     ^^^^^^^^^^^ help: try: `f32::from(1u16)`
 
 error: casting u16 to f64 may become silently lossy if types change
-  --> $DIR/cast_lossless_float.rs:21:5
+  --> $DIR/cast_lossless_float.rs:23:5
    |
 LL |     1u16 as f64;
    |     ^^^^^^^^^^^ help: try: `f64::from(1u16)`
 
 error: casting i32 to f64 may become silently lossy if types change
-  --> $DIR/cast_lossless_float.rs:22:5
+  --> $DIR/cast_lossless_float.rs:24:5
    |
 LL |     1i32 as f64;
    |     ^^^^^^^^^^^ help: try: `f64::from(1i32)`
 
 error: casting u32 to f64 may become silently lossy if types change
-  --> $DIR/cast_lossless_float.rs:23:5
+  --> $DIR/cast_lossless_float.rs:25:5
    |
 LL |     1u32 as f64;
    |     ^^^^^^^^^^^ help: try: `f64::from(1u32)`
diff --git a/tests/ui/cast_lossless_integer.fixed b/tests/ui/cast_lossless_integer.fixed
new file mode 100644
index 00000000000..83f3e024209
--- /dev/null
+++ b/tests/ui/cast_lossless_integer.fixed
@@ -0,0 +1,34 @@
+// 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
+
+#[warn(clippy::cast_lossless)]
+#[allow(clippy::no_effect, clippy::unnecessary_operation)]
+fn main() {
+    // Test clippy::cast_lossless with casts to integer types
+    i16::from(1i8);
+    i32::from(1i8);
+    i64::from(1i8);
+    i16::from(1u8);
+    i32::from(1u8);
+    i64::from(1u8);
+    u16::from(1u8);
+    u32::from(1u8);
+    u64::from(1u8);
+    i32::from(1i16);
+    i64::from(1i16);
+    i32::from(1u16);
+    i64::from(1u16);
+    u32::from(1u16);
+    u64::from(1u16);
+    i64::from(1i32);
+    i64::from(1u32);
+    u64::from(1u32);
+}
diff --git a/tests/ui/cast_lossless_integer.rs b/tests/ui/cast_lossless_integer.rs
index 593ffdd2766..75c63957001 100644
--- a/tests/ui/cast_lossless_integer.rs
+++ b/tests/ui/cast_lossless_integer.rs
@@ -7,6 +7,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// run-rustfix
+
 #[warn(clippy::cast_lossless)]
 #[allow(clippy::no_effect, clippy::unnecessary_operation)]
 fn main() {
diff --git a/tests/ui/cast_lossless_integer.stderr b/tests/ui/cast_lossless_integer.stderr
index d9eb1be57f7..f49dc0d9eff 100644
--- a/tests/ui/cast_lossless_integer.stderr
+++ b/tests/ui/cast_lossless_integer.stderr
@@ -1,5 +1,5 @@
 error: casting i8 to i16 may become silently lossy if types change
-  --> $DIR/cast_lossless_integer.rs:14:5
+  --> $DIR/cast_lossless_integer.rs:16:5
    |
 LL |     1i8 as i16;
    |     ^^^^^^^^^^ help: try: `i16::from(1i8)`
@@ -7,103 +7,103 @@ LL |     1i8 as i16;
    = note: `-D clippy::cast-lossless` implied by `-D warnings`
 
 error: casting i8 to i32 may become silently lossy if types change
-  --> $DIR/cast_lossless_integer.rs:15:5
+  --> $DIR/cast_lossless_integer.rs:17:5
    |
 LL |     1i8 as i32;
    |     ^^^^^^^^^^ help: try: `i32::from(1i8)`
 
 error: casting i8 to i64 may become silently lossy if types change
-  --> $DIR/cast_lossless_integer.rs:16:5
+  --> $DIR/cast_lossless_integer.rs:18:5
    |
 LL |     1i8 as i64;
    |     ^^^^^^^^^^ help: try: `i64::from(1i8)`
 
 error: casting u8 to i16 may become silently lossy if types change
-  --> $DIR/cast_lossless_integer.rs:17:5
+  --> $DIR/cast_lossless_integer.rs:19:5
    |
 LL |     1u8 as i16;
    |     ^^^^^^^^^^ help: try: `i16::from(1u8)`
 
 error: casting u8 to i32 may become silently lossy if types change
-  --> $DIR/cast_lossless_integer.rs:18:5
+  --> $DIR/cast_lossless_integer.rs:20:5
    |
 LL |     1u8 as i32;
    |     ^^^^^^^^^^ help: try: `i32::from(1u8)`
 
 error: casting u8 to i64 may become silently lossy if types change
-  --> $DIR/cast_lossless_integer.rs:19:5
+  --> $DIR/cast_lossless_integer.rs:21:5
    |
 LL |     1u8 as i64;
    |     ^^^^^^^^^^ help: try: `i64::from(1u8)`
 
 error: casting u8 to u16 may become silently lossy if types change
-  --> $DIR/cast_lossless_integer.rs:20:5
+  --> $DIR/cast_lossless_integer.rs:22:5
    |
 LL |     1u8 as u16;
    |     ^^^^^^^^^^ help: try: `u16::from(1u8)`
 
 error: casting u8 to u32 may become silently lossy if types change
-  --> $DIR/cast_lossless_integer.rs:21:5
+  --> $DIR/cast_lossless_integer.rs:23:5
    |
 LL |     1u8 as u32;
    |     ^^^^^^^^^^ help: try: `u32::from(1u8)`
 
 error: casting u8 to u64 may become silently lossy if types change
-  --> $DIR/cast_lossless_integer.rs:22:5
+  --> $DIR/cast_lossless_integer.rs:24:5
    |
 LL |     1u8 as u64;
    |     ^^^^^^^^^^ help: try: `u64::from(1u8)`
 
 error: casting i16 to i32 may become silently lossy if types change
-  --> $DIR/cast_lossless_integer.rs:23:5
+  --> $DIR/cast_lossless_integer.rs:25:5
    |
 LL |     1i16 as i32;
    |     ^^^^^^^^^^^ help: try: `i32::from(1i16)`
 
 error: casting i16 to i64 may become silently lossy if types change
-  --> $DIR/cast_lossless_integer.rs:24:5
+  --> $DIR/cast_lossless_integer.rs:26:5
    |
 LL |     1i16 as i64;
    |     ^^^^^^^^^^^ help: try: `i64::from(1i16)`
 
 error: casting u16 to i32 may become silently lossy if types change
-  --> $DIR/cast_lossless_integer.rs:25:5
+  --> $DIR/cast_lossless_integer.rs:27:5
    |
 LL |     1u16 as i32;
    |     ^^^^^^^^^^^ help: try: `i32::from(1u16)`
 
 error: casting u16 to i64 may become silently lossy if types change
-  --> $DIR/cast_lossless_integer.rs:26:5
+  --> $DIR/cast_lossless_integer.rs:28:5
    |
 LL |     1u16 as i64;
    |     ^^^^^^^^^^^ help: try: `i64::from(1u16)`
 
 error: casting u16 to u32 may become silently lossy if types change
-  --> $DIR/cast_lossless_integer.rs:27:5
+  --> $DIR/cast_lossless_integer.rs:29:5
    |
 LL |     1u16 as u32;
    |     ^^^^^^^^^^^ help: try: `u32::from(1u16)`
 
 error: casting u16 to u64 may become silently lossy if types change
-  --> $DIR/cast_lossless_integer.rs:28:5
+  --> $DIR/cast_lossless_integer.rs:30:5
    |
 LL |     1u16 as u64;
    |     ^^^^^^^^^^^ help: try: `u64::from(1u16)`
 
 error: casting i32 to i64 may become silently lossy if types change
-  --> $DIR/cast_lossless_integer.rs:29:5
+  --> $DIR/cast_lossless_integer.rs:31:5
    |
 LL |     1i32 as i64;
    |     ^^^^^^^^^^^ help: try: `i64::from(1i32)`
 
 error: casting u32 to i64 may become silently lossy if types change
-  --> $DIR/cast_lossless_integer.rs:30:5
+  --> $DIR/cast_lossless_integer.rs:32:5
    |
 LL |     1u32 as i64;
    |     ^^^^^^^^^^^ help: try: `i64::from(1u32)`
 
 error: casting u32 to u64 may become silently lossy if types change
-  --> $DIR/cast_lossless_integer.rs:31:5
+  --> $DIR/cast_lossless_integer.rs:33:5
    |
 LL |     1u32 as u64;
    |     ^^^^^^^^^^^ help: try: `u64::from(1u32)`
diff --git a/tests/ui/double_comparison.fixed b/tests/ui/double_comparison.fixed
new file mode 100644
index 00000000000..fd98edb7555
--- /dev/null
+++ b/tests/ui/double_comparison.fixed
@@ -0,0 +1,39 @@
+// 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
+
+fn main() {
+    let x = 1;
+    let y = 2;
+    if x <= y {
+        // do something
+    }
+    if x <= y {
+        // do something
+    }
+    if x >= y {
+        // do something
+    }
+    if x >= y {
+        // do something
+    }
+    if x != y {
+        // do something
+    }
+    if x != y {
+        // do something
+    }
+    if x == y {
+        // do something
+    }
+    if x == y {
+        // do something
+    }
+}
diff --git a/tests/ui/double_comparison.rs b/tests/ui/double_comparison.rs
index 70b837a75b6..5d201a13ff2 100644
--- a/tests/ui/double_comparison.rs
+++ b/tests/ui/double_comparison.rs
@@ -7,6 +7,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// run-rustfix
+
 fn main() {
     let x = 1;
     let y = 2;
diff --git a/tests/ui/double_comparison.stderr b/tests/ui/double_comparison.stderr
index f4ec229fbfd..31bab8f0112 100644
--- a/tests/ui/double_comparison.stderr
+++ b/tests/ui/double_comparison.stderr
@@ -1,5 +1,5 @@
 error: This binary expression can be simplified
-  --> $DIR/double_comparison.rs:13:8
+  --> $DIR/double_comparison.rs:15:8
    |
 LL |     if x == y || x < y {
    |        ^^^^^^^^^^^^^^^ help: try: `x <= y`
@@ -7,43 +7,43 @@ LL |     if x == y || x < y {
    = note: `-D clippy::double-comparisons` implied by `-D warnings`
 
 error: This binary expression can be simplified
-  --> $DIR/double_comparison.rs:16:8
+  --> $DIR/double_comparison.rs:18:8
    |
 LL |     if x < y || x == y {
    |        ^^^^^^^^^^^^^^^ help: try: `x <= y`
 
 error: This binary expression can be simplified
-  --> $DIR/double_comparison.rs:19:8
+  --> $DIR/double_comparison.rs:21:8
    |
 LL |     if x == y || x > y {
    |        ^^^^^^^^^^^^^^^ help: try: `x >= y`
 
 error: This binary expression can be simplified
-  --> $DIR/double_comparison.rs:22:8
+  --> $DIR/double_comparison.rs:24:8
    |
 LL |     if x > y || x == y {
    |        ^^^^^^^^^^^^^^^ help: try: `x >= y`
 
 error: This binary expression can be simplified
-  --> $DIR/double_comparison.rs:25:8
+  --> $DIR/double_comparison.rs:27:8
    |
 LL |     if x < y || x > y {
    |        ^^^^^^^^^^^^^^ help: try: `x != y`
 
 error: This binary expression can be simplified
-  --> $DIR/double_comparison.rs:28:8
+  --> $DIR/double_comparison.rs:30:8
    |
 LL |     if x > y || x < y {
    |        ^^^^^^^^^^^^^^ help: try: `x != y`
 
 error: This binary expression can be simplified
-  --> $DIR/double_comparison.rs:31:8
+  --> $DIR/double_comparison.rs:33:8
    |
 LL |     if x <= y && x >= y {
    |        ^^^^^^^^^^^^^^^^ help: try: `x == y`
 
 error: This binary expression can be simplified
-  --> $DIR/double_comparison.rs:34:8
+  --> $DIR/double_comparison.rs:36:8
    |
 LL |     if x >= y && x <= y {
    |        ^^^^^^^^^^^^^^^^ help: try: `x == y`
diff --git a/tests/ui/println_empty_string.fixed b/tests/ui/println_empty_string.fixed
new file mode 100644
index 00000000000..4ca151453fe
--- /dev/null
+++ b/tests/ui/println_empty_string.fixed
@@ -0,0 +1,19 @@
+// 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
+
+fn main() {
+    println!();
+    println!();
+
+    match "a" {
+        _ => println!(),
+    }
+}
diff --git a/tests/ui/println_empty_string.rs b/tests/ui/println_empty_string.rs
index 19a0389762a..21f944916db 100644
--- a/tests/ui/println_empty_string.rs
+++ b/tests/ui/println_empty_string.rs
@@ -7,6 +7,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// run-rustfix
+
 fn main() {
     println!();
     println!("");
diff --git a/tests/ui/println_empty_string.stderr b/tests/ui/println_empty_string.stderr
index 89447040a33..2370a3f1e28 100644
--- a/tests/ui/println_empty_string.stderr
+++ b/tests/ui/println_empty_string.stderr
@@ -1,5 +1,5 @@
 error: using `println!("")`
-  --> $DIR/println_empty_string.rs:12:5
+  --> $DIR/println_empty_string.rs:14:5
    |
 LL |     println!("");
    |     ^^^^^^^^^^^^ help: replace it with: `println!()`
@@ -7,7 +7,7 @@ LL |     println!("");
    = note: `-D clippy::println-empty-string` implied by `-D warnings`
 
 error: using `println!("")`
-  --> $DIR/println_empty_string.rs:15:14
+  --> $DIR/println_empty_string.rs:17:14
    |
 LL |         _ => println!(""),
    |              ^^^^^^^^^^^^ help: replace it with: `println!()`
diff --git a/tests/ui/ptr_offset_with_cast.fixed b/tests/ui/ptr_offset_with_cast.fixed
new file mode 100644
index 00000000000..c9f58896ae1
--- /dev/null
+++ b/tests/ui/ptr_offset_with_cast.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
+
+fn main() {
+    let vec = vec![b'a', b'b', b'c'];
+    let ptr = vec.as_ptr();
+
+    let offset_u8 = 1_u8;
+    let offset_usize = 1_usize;
+    let offset_isize = 1_isize;
+
+    unsafe {
+        ptr.add(offset_usize);
+        ptr.offset(offset_isize as isize);
+        ptr.offset(offset_u8 as isize);
+
+        ptr.wrapping_add(offset_usize);
+        ptr.wrapping_offset(offset_isize as isize);
+        ptr.wrapping_offset(offset_u8 as isize);
+    }
+}
diff --git a/tests/ui/ptr_offset_with_cast.rs b/tests/ui/ptr_offset_with_cast.rs
index 2c9e47d3f32..23eb4c6ce8a 100644
--- a/tests/ui/ptr_offset_with_cast.rs
+++ b/tests/ui/ptr_offset_with_cast.rs
@@ -7,6 +7,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// run-rustfix
+
 fn main() {
     let vec = vec![b'a', b'b', b'c'];
     let ptr = vec.as_ptr();
diff --git a/tests/ui/ptr_offset_with_cast.stderr b/tests/ui/ptr_offset_with_cast.stderr
index d1795f439b2..98e3ff92a6e 100644
--- a/tests/ui/ptr_offset_with_cast.stderr
+++ b/tests/ui/ptr_offset_with_cast.stderr
@@ -1,5 +1,5 @@
 error: use of `offset` with a `usize` casted to an `isize`
-  --> $DIR/ptr_offset_with_cast.rs:19:9
+  --> $DIR/ptr_offset_with_cast.rs:21:9
    |
 LL |         ptr.offset(offset_usize as isize);
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `ptr.add(offset_usize)`
@@ -7,7 +7,7 @@ LL |         ptr.offset(offset_usize as isize);
    = note: `-D clippy::ptr-offset-with-cast` implied by `-D warnings`
 
 error: use of `wrapping_offset` with a `usize` casted to an `isize`
-  --> $DIR/ptr_offset_with_cast.rs:23:9
+  --> $DIR/ptr_offset_with_cast.rs:25:9
    |
 LL |         ptr.wrapping_offset(offset_usize as isize);
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `ptr.wrapping_add(offset_usize)`
diff --git a/tests/ui/single_char_pattern.fixed b/tests/ui/single_char_pattern.fixed
new file mode 100644
index 00000000000..c3c399f0ce3
--- /dev/null
+++ b/tests/ui/single_char_pattern.fixed
@@ -0,0 +1,61 @@
+// 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
+
+use std::collections::HashSet;
+
+fn main() {
+    let x = "foo";
+    x.split('x');
+    x.split("xx");
+    x.split('x');
+
+    let y = "x";
+    x.split(y);
+    // Not yet testing for multi-byte characters
+    // Changing `r.len() == 1` to `r.chars().count() == 1` in `lint_clippy::single_char_pattern`
+    // should have done this but produced an ICE
+    //
+    // We may not want to suggest changing these anyway
+    // See: https://github.com/rust-lang/rust-clippy/issues/650#issuecomment-184328984
+    x.split("ß");
+    x.split("ℝ");
+    x.split("💣");
+    // Can't use this lint for unicode code points which don't fit in a char
+    x.split("❤️");
+    x.contains('x');
+    x.starts_with('x');
+    x.ends_with('x');
+    x.find('x');
+    x.rfind('x');
+    x.rsplit('x');
+    x.split_terminator('x');
+    x.rsplit_terminator('x');
+    x.splitn(0, 'x');
+    x.rsplitn(0, 'x');
+    x.matches('x');
+    x.rmatches('x');
+    x.match_indices('x');
+    x.rmatch_indices('x');
+    x.trim_start_matches('x');
+    x.trim_end_matches('x');
+    // Make sure we escape characters correctly.
+    x.split('\n');
+
+    let h = HashSet::<String>::new();
+    h.contains("X"); // should not warn
+
+    x.replace(";", ",").split(','); // issue #2978
+    x.starts_with('\x03'); // issue #2996
+
+    // Issue #3204
+    const S: &str = "#";
+    x.find(S);
+}
diff --git a/tests/ui/single_char_pattern.rs b/tests/ui/single_char_pattern.rs
index eeee953ab84..cf2fe66236a 100644
--- a/tests/ui/single_char_pattern.rs
+++ b/tests/ui/single_char_pattern.rs
@@ -7,6 +7,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// run-rustfix
+
 use std::collections::HashSet;
 
 fn main() {
diff --git a/tests/ui/single_char_pattern.stderr b/tests/ui/single_char_pattern.stderr
index 7fa3211ab72..7bc92a96536 100644
--- a/tests/ui/single_char_pattern.stderr
+++ b/tests/ui/single_char_pattern.stderr
@@ -1,5 +1,5 @@
 error: single-character string constant used as pattern
-  --> $DIR/single_char_pattern.rs:14:13
+  --> $DIR/single_char_pattern.rs:16:13
    |
 LL |     x.split("x");
    |             ^^^ help: try using a char instead: `'x'`
@@ -7,115 +7,115 @@ LL |     x.split("x");
    = note: `-D clippy::single-char-pattern` implied by `-D warnings`
 
 error: single-character string constant used as pattern
-  --> $DIR/single_char_pattern.rs:31:16
+  --> $DIR/single_char_pattern.rs:33:16
    |
 LL |     x.contains("x");
    |                ^^^ help: try using a char instead: `'x'`
 
 error: single-character string constant used as pattern
-  --> $DIR/single_char_pattern.rs:32:19
+  --> $DIR/single_char_pattern.rs:34:19
    |
 LL |     x.starts_with("x");
    |                   ^^^ help: try using a char instead: `'x'`
 
 error: single-character string constant used as pattern
-  --> $DIR/single_char_pattern.rs:33:17
+  --> $DIR/single_char_pattern.rs:35:17
    |
 LL |     x.ends_with("x");
    |                 ^^^ help: try using a char instead: `'x'`
 
 error: single-character string constant used as pattern
-  --> $DIR/single_char_pattern.rs:34:12
+  --> $DIR/single_char_pattern.rs:36:12
    |
 LL |     x.find("x");
    |            ^^^ help: try using a char instead: `'x'`
 
 error: single-character string constant used as pattern
-  --> $DIR/single_char_pattern.rs:35:13
+  --> $DIR/single_char_pattern.rs:37:13
    |
 LL |     x.rfind("x");
    |             ^^^ help: try using a char instead: `'x'`
 
 error: single-character string constant used as pattern
-  --> $DIR/single_char_pattern.rs:36:14
+  --> $DIR/single_char_pattern.rs:38:14
    |
 LL |     x.rsplit("x");
    |              ^^^ help: try using a char instead: `'x'`
 
 error: single-character string constant used as pattern
-  --> $DIR/single_char_pattern.rs:37:24
+  --> $DIR/single_char_pattern.rs:39:24
    |
 LL |     x.split_terminator("x");
    |                        ^^^ help: try using a char instead: `'x'`
 
 error: single-character string constant used as pattern
-  --> $DIR/single_char_pattern.rs:38:25
+  --> $DIR/single_char_pattern.rs:40:25
    |
 LL |     x.rsplit_terminator("x");
    |                         ^^^ help: try using a char instead: `'x'`
 
 error: single-character string constant used as pattern
-  --> $DIR/single_char_pattern.rs:39:17
+  --> $DIR/single_char_pattern.rs:41:17
    |
 LL |     x.splitn(0, "x");
    |                 ^^^ help: try using a char instead: `'x'`
 
 error: single-character string constant used as pattern
-  --> $DIR/single_char_pattern.rs:40:18
+  --> $DIR/single_char_pattern.rs:42:18
    |
 LL |     x.rsplitn(0, "x");
    |                  ^^^ help: try using a char instead: `'x'`
 
 error: single-character string constant used as pattern
-  --> $DIR/single_char_pattern.rs:41:15
+  --> $DIR/single_char_pattern.rs:43:15
    |
 LL |     x.matches("x");
    |               ^^^ help: try using a char instead: `'x'`
 
 error: single-character string constant used as pattern
-  --> $DIR/single_char_pattern.rs:42:16
+  --> $DIR/single_char_pattern.rs:44:16
    |
 LL |     x.rmatches("x");
    |                ^^^ help: try using a char instead: `'x'`
 
 error: single-character string constant used as pattern
-  --> $DIR/single_char_pattern.rs:43:21
+  --> $DIR/single_char_pattern.rs:45:21
    |
 LL |     x.match_indices("x");
    |                     ^^^ help: try using a char instead: `'x'`
 
 error: single-character string constant used as pattern
-  --> $DIR/single_char_pattern.rs:44:22
+  --> $DIR/single_char_pattern.rs:46:22
    |
 LL |     x.rmatch_indices("x");
    |                      ^^^ help: try using a char instead: `'x'`
 
 error: single-character string constant used as pattern
-  --> $DIR/single_char_pattern.rs:45:26
+  --> $DIR/single_char_pattern.rs:47:26
    |
 LL |     x.trim_start_matches("x");
    |                          ^^^ help: try using a char instead: `'x'`
 
 error: single-character string constant used as pattern
-  --> $DIR/single_char_pattern.rs:46:24
+  --> $DIR/single_char_pattern.rs:48:24
    |
 LL |     x.trim_end_matches("x");
    |                        ^^^ help: try using a char instead: `'x'`
 
 error: single-character string constant used as pattern
-  --> $DIR/single_char_pattern.rs:48:13
+  --> $DIR/single_char_pattern.rs:50:13
    |
 LL |     x.split("/n");
    |             ^^^^ help: try using a char instead: `'/n'`
 
 error: single-character string constant used as pattern
-  --> $DIR/single_char_pattern.rs:53:31
+  --> $DIR/single_char_pattern.rs:55:31
    |
 LL |     x.replace(";", ",").split(","); // issue #2978
    |                               ^^^ help: try using a char instead: `','`
 
 error: single-character string constant used as pattern
-  --> $DIR/single_char_pattern.rs:54:19
+  --> $DIR/single_char_pattern.rs:56:19
    |
 LL |     x.starts_with("/x03"); // issue #2996
    |                   ^^^^^^ help: try using a char instead: `'/x03'`
diff --git a/tests/ui/string_extend.fixed b/tests/ui/string_extend.fixed
new file mode 100644
index 00000000000..7463baff2af
--- /dev/null
+++ b/tests/ui/string_extend.fixed
@@ -0,0 +1,41 @@
+// 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
+
+#[derive(Copy, Clone)]
+struct HasChars;
+
+impl HasChars {
+    fn chars(self) -> std::str::Chars<'static> {
+        "HasChars".chars()
+    }
+}
+
+fn main() {
+    let abc = "abc";
+    let def = String::from("def");
+    let mut s = String::new();
+
+    s.push_str(abc);
+    s.push_str(abc);
+
+    s.push_str("abc");
+    s.push_str("abc");
+
+    s.push_str(&def);
+    s.push_str(&def);
+
+    s.extend(abc.chars().skip(1));
+    s.extend("abc".chars().skip(1));
+    s.extend(['a', 'b', 'c'].iter());
+
+    let f = HasChars;
+    s.extend(f.chars());
+}
diff --git a/tests/ui/string_extend.rs b/tests/ui/string_extend.rs
index 56b466ede20..3a2ad2695de 100644
--- a/tests/ui/string_extend.rs
+++ b/tests/ui/string_extend.rs
@@ -7,6 +7,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// run-rustfix
+
 #[derive(Copy, Clone)]
 struct HasChars;
 
diff --git a/tests/ui/string_extend.stderr b/tests/ui/string_extend.stderr
index 80a490b7884..5638dd87ed1 100644
--- a/tests/ui/string_extend.stderr
+++ b/tests/ui/string_extend.stderr
@@ -1,5 +1,5 @@
 error: calling `.extend(_.chars())`
-  --> $DIR/string_extend.rs:25:5
+  --> $DIR/string_extend.rs:27:5
    |
 LL |     s.extend(abc.chars());
    |     ^^^^^^^^^^^^^^^^^^^^^ help: try this: `s.push_str(abc)`
@@ -7,13 +7,13 @@ LL |     s.extend(abc.chars());
    = note: `-D clippy::string-extend-chars` implied by `-D warnings`
 
 error: calling `.extend(_.chars())`
-  --> $DIR/string_extend.rs:28:5
+  --> $DIR/string_extend.rs:30:5
    |
 LL |     s.extend("abc".chars());
    |     ^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `s.push_str("abc")`
 
 error: calling `.extend(_.chars())`
-  --> $DIR/string_extend.rs:31:5
+  --> $DIR/string_extend.rs:33:5
    |
 LL |     s.extend(def.chars());
    |     ^^^^^^^^^^^^^^^^^^^^^ help: try this: `s.push_str(&def)`
diff --git a/tests/ui/unreadable_literal.fixed b/tests/ui/unreadable_literal.fixed
new file mode 100644
index 00000000000..4c466035a04
--- /dev/null
+++ b/tests/ui/unreadable_literal.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
+
+#[warn(clippy::unreadable_literal)]
+#[allow(unused_variables)]
+fn main() {
+    let good = (
+        0b1011_i64,
+        0o1_234_u32,
+        0x1_234_567,
+        65536,
+        1_2345_6789,
+        1234_f32,
+        1_234.12_f32,
+        1_234.123_f32,
+        1.123_4_f32,
+    );
+    let bad = (0b11_0110_i64, 0x0123_4567_8901_usize, 123_456_f32, 1.234_567_f32);
+    let good_sci = 1.1234e1;
+    let bad_sci = 1.123_456e1;
+}
diff --git a/tests/ui/unreadable_literal.rs b/tests/ui/unreadable_literal.rs
index ad29fcf8fe4..8ade2f6a863 100644
--- a/tests/ui/unreadable_literal.rs
+++ b/tests/ui/unreadable_literal.rs
@@ -7,6 +7,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// run-rustfix
+
 #[warn(clippy::unreadable_literal)]
 #[allow(unused_variables)]
 fn main() {
diff --git a/tests/ui/unreadable_literal.stderr b/tests/ui/unreadable_literal.stderr
index 6696f155fb8..68580485853 100644
--- a/tests/ui/unreadable_literal.stderr
+++ b/tests/ui/unreadable_literal.stderr
@@ -1,5 +1,5 @@
 error: long literal lacking separators
-  --> $DIR/unreadable_literal.rs:24:16
+  --> $DIR/unreadable_literal.rs:26:16
    |
 LL |     let bad = (0b110110_i64, 0x12345678901_usize, 123456_f32, 1.234567_f32);
    |                ^^^^^^^^^^^^ help: consider: `0b11_0110_i64`
@@ -7,25 +7,25 @@ LL |     let bad = (0b110110_i64, 0x12345678901_usize, 123456_f32, 1.234567_f32)
    = note: `-D clippy::unreadable-literal` implied by `-D warnings`
 
 error: long literal lacking separators
-  --> $DIR/unreadable_literal.rs:24:30
+  --> $DIR/unreadable_literal.rs:26:30
    |
 LL |     let bad = (0b110110_i64, 0x12345678901_usize, 123456_f32, 1.234567_f32);
    |                              ^^^^^^^^^^^^^^^^^^^ help: consider: `0x0123_4567_8901_usize`
 
 error: long literal lacking separators
-  --> $DIR/unreadable_literal.rs:24:51
+  --> $DIR/unreadable_literal.rs:26:51
    |
 LL |     let bad = (0b110110_i64, 0x12345678901_usize, 123456_f32, 1.234567_f32);
    |                                                   ^^^^^^^^^^ help: consider: `123_456_f32`
 
 error: long literal lacking separators
-  --> $DIR/unreadable_literal.rs:24:63
+  --> $DIR/unreadable_literal.rs:26:63
    |
 LL |     let bad = (0b110110_i64, 0x12345678901_usize, 123456_f32, 1.234567_f32);
    |                                                               ^^^^^^^^^^^^ help: consider: `1.234_567_f32`
 
 error: long literal lacking separators
-  --> $DIR/unreadable_literal.rs:26:19
+  --> $DIR/unreadable_literal.rs:28:19
    |
 LL |     let bad_sci = 1.123456e1;
    |                   ^^^^^^^^^^ help: consider: `1.123_456e1`
diff --git a/tests/ui/vec.fixed b/tests/ui/vec.fixed
new file mode 100644
index 00000000000..2eaba1c408a
--- /dev/null
+++ b/tests/ui/vec.fixed
@@ -0,0 +1,64 @@
+// 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
+
+#![warn(clippy::useless_vec)]
+
+#[derive(Debug)]
+struct NonCopy;
+
+fn on_slice(_: &[u8]) {}
+#[allow(clippy::ptr_arg)]
+fn on_vec(_: &Vec<u8>) {}
+
+struct Line {
+    length: usize,
+}
+
+impl Line {
+    fn length(&self) -> usize {
+        self.length
+    }
+}
+
+fn main() {
+    on_slice(&[]);
+    on_slice(&[]);
+
+    on_slice(&[1, 2]);
+    on_slice(&[1, 2]);
+
+    on_slice(&[1, 2]);
+    on_slice(&[1, 2]);
+    #[rustfmt::skip]
+    on_slice(&[1, 2]);
+    on_slice(&[1, 2]);
+
+    on_slice(&[1; 2]);
+    on_slice(&[1; 2]);
+
+    on_vec(&vec![]);
+    on_vec(&vec![1, 2]);
+    on_vec(&vec![1; 2]);
+
+    // Now with non-constant expressions
+    let line = Line { length: 2 };
+
+    on_slice(&vec![2; line.length]);
+    on_slice(&vec![2; line.length()]);
+
+    for a in &[1, 2, 3] {
+        println!("{:?}", a);
+    }
+
+    for a in vec![NonCopy, NonCopy] {
+        println!("{:?}", a);
+    }
+}
diff --git a/tests/ui/vec.rs b/tests/ui/vec.rs
index f795c11ec5b..1648215ed35 100644
--- a/tests/ui/vec.rs
+++ b/tests/ui/vec.rs
@@ -7,6 +7,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// run-rustfix
+
 #![warn(clippy::useless_vec)]
 
 #[derive(Debug)]
diff --git a/tests/ui/vec.stderr b/tests/ui/vec.stderr
index 0afb95629d9..96dd187ccc5 100644
--- a/tests/ui/vec.stderr
+++ b/tests/ui/vec.stderr
@@ -1,5 +1,5 @@
 error: useless use of `vec!`
-  --> $DIR/vec.rs:30:14
+  --> $DIR/vec.rs:32:14
    |
 LL |     on_slice(&vec![]);
    |              ^^^^^^^ help: you can use a slice directly: `&[]`
@@ -7,31 +7,31 @@ LL |     on_slice(&vec![]);
    = note: `-D clippy::useless-vec` implied by `-D warnings`
 
 error: useless use of `vec!`
-  --> $DIR/vec.rs:33:14
+  --> $DIR/vec.rs:35:14
    |
 LL |     on_slice(&vec![1, 2]);
    |              ^^^^^^^^^^^ help: you can use a slice directly: `&[1, 2]`
 
 error: useless use of `vec!`
-  --> $DIR/vec.rs:36:14
+  --> $DIR/vec.rs:38:14
    |
 LL |     on_slice(&vec![1, 2]);
    |              ^^^^^^^^^^^ help: you can use a slice directly: `&[1, 2]`
 
 error: useless use of `vec!`
-  --> $DIR/vec.rs:39:14
+  --> $DIR/vec.rs:41:14
    |
 LL |     on_slice(&vec!(1, 2));
    |              ^^^^^^^^^^^ help: you can use a slice directly: `&[1, 2]`
 
 error: useless use of `vec!`
-  --> $DIR/vec.rs:42:14
+  --> $DIR/vec.rs:44:14
    |
 LL |     on_slice(&vec![1; 2]);
    |              ^^^^^^^^^^^ help: you can use a slice directly: `&[1; 2]`
 
 error: useless use of `vec!`
-  --> $DIR/vec.rs:55:14
+  --> $DIR/vec.rs:57:14
    |
 LL |     for a in vec![1, 2, 3] {
    |              ^^^^^^^^^^^^^ help: you can use a slice directly: `&[1, 2, 3]`
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, "");
+}
diff --git a/tests/ui/writeln_empty_string.rs b/tests/ui/writeln_empty_string.rs
index 71b5df48bfa..ba43552af23 100644
--- a/tests/ui/writeln_empty_string.rs
+++ b/tests/ui/writeln_empty_string.rs
@@ -7,6 +7,8 @@
 // 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;
diff --git a/tests/ui/writeln_empty_string.stderr b/tests/ui/writeln_empty_string.stderr
index 9b4061f0fe4..119710c0cdb 100644
--- a/tests/ui/writeln_empty_string.stderr
+++ b/tests/ui/writeln_empty_string.stderr
@@ -1,5 +1,5 @@
 error: using `writeln!(&mut v, "")`
-  --> $DIR/writeln_empty_string.rs:18:5
+  --> $DIR/writeln_empty_string.rs:20:5
    |
 LL |     writeln!(&mut v, "");
    |     ^^^^^^^^^^^^^^^^^^^^ help: replace it with: `writeln!(&mut v)`
@@ -7,7 +7,7 @@ LL |     writeln!(&mut v, "");
    = note: `-D clippy::writeln-empty-string` implied by `-D warnings`
 
 error: using `writeln!(&mut suggestion, "")`
-  --> $DIR/writeln_empty_string.rs:21:5
+  --> $DIR/writeln_empty_string.rs:23:5
    |
 LL |     writeln!(&mut suggestion, "");
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `writeln!(&mut suggestion)`