about summary refs log tree commit diff
diff options
context:
space:
mode:
authorWilco Kusee <wilcokusee@gmail.com>2019-01-13 13:55:26 +0100
committerWilco Kusee <wilcokusee@gmail.com>2019-01-13 13:55:26 +0100
commit95f2a9dbfcaaf8b319c2743ea641b785ff4c9d2e (patch)
tree1a0bbc7311485400c4170b05562798c238710245
parent9ff821a7e822cbc81d4370202bd1af08c2d18c63 (diff)
downloadrust-95f2a9dbfcaaf8b319c2743ea641b785ff4c9d2e.tar.gz
rust-95f2a9dbfcaaf8b319c2743ea641b785ff4c9d2e.zip
Add run-rustfix to mem_replace test
-rw-r--r--tests/ui/mem_replace.fixed21
-rw-r--r--tests/ui/mem_replace.rs2
-rw-r--r--tests/ui/mem_replace.stderr4
3 files changed, 25 insertions, 2 deletions
diff --git a/tests/ui/mem_replace.fixed b/tests/ui/mem_replace.fixed
new file mode 100644
index 00000000000..4e47ac95d82
--- /dev/null
+++ b/tests/ui/mem_replace.fixed
@@ -0,0 +1,21 @@
+// Copyright 2014-2019 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_imports)]
+#![warn(clippy::all, clippy::style, clippy::mem_replace_option_with_none)]
+
+use std::mem;
+
+fn main() {
+    let mut an_option = Some(1);
+    let _ = an_option.take();
+    let an_option = &mut Some(1);
+    let _ = an_option.take();
+}
diff --git a/tests/ui/mem_replace.rs b/tests/ui/mem_replace.rs
index a0c340bb54b..6824ab18e7f 100644
--- a/tests/ui/mem_replace.rs
+++ b/tests/ui/mem_replace.rs
@@ -7,6 +7,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// run-rustfix
+#![allow(unused_imports)]
 #![warn(clippy::all, clippy::style, clippy::mem_replace_option_with_none)]
 
 use std::mem;
diff --git a/tests/ui/mem_replace.stderr b/tests/ui/mem_replace.stderr
index 9092fa2ea14..791c4d71dbf 100644
--- a/tests/ui/mem_replace.stderr
+++ b/tests/ui/mem_replace.stderr
@@ -1,5 +1,5 @@
 error: replacing an `Option` with `None`
-  --> $DIR/mem_replace.rs:16:13
+  --> $DIR/mem_replace.rs:18:13
    |
 LL |     let _ = mem::replace(&mut an_option, None);
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider `Option::take()` instead: `an_option.take()`
@@ -7,7 +7,7 @@ LL |     let _ = mem::replace(&mut an_option, None);
    = note: `-D clippy::mem-replace-option-with-none` implied by `-D warnings`
 
 error: replacing an `Option` with `None`
-  --> $DIR/mem_replace.rs:18:13
+  --> $DIR/mem_replace.rs:20:13
    |
 LL |     let _ = mem::replace(an_option, None);
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider `Option::take()` instead: `an_option.take()`