]> git.lizzy.rs Git - rust.git/commitdiff
Add run-rustfix to map_clone test
authorWilco Kusee <wilcokusee@gmail.com>
Sun, 13 Jan 2019 12:10:25 +0000 (13:10 +0100)
committerWilco Kusee <wilcokusee@gmail.com>
Sun, 13 Jan 2019 12:10:25 +0000 (13:10 +0100)
tests/ui/map_clone.fixed [new file with mode: 0644]
tests/ui/map_clone.rs
tests/ui/map_clone.stderr

diff --git a/tests/ui/map_clone.fixed b/tests/ui/map_clone.fixed
new file mode 100644 (file)
index 0000000..5c41948
--- /dev/null
@@ -0,0 +1,11 @@
+// run-rustfix
+#![warn(clippy::all, clippy::pedantic)]
+#![allow(clippy::iter_cloned_collect)]
+#![allow(clippy::missing_docs_in_private_items)]
+
+fn main() {
+    let _: Vec<i8> = vec![5_i8; 6].iter().cloned().collect();
+    let _: Vec<String> = vec![String::new()].iter().cloned().collect();
+    let _: Vec<u32> = vec![42, 43].iter().cloned().collect();
+    let _: Option<u64> = Some(Box::new(16)).map(|b| *b);
+}
index a70cb2f67258dd6a2ee68a345cde61bbfc32ce79..96a615ae54c8c2dc9066edd8baf5fa08a91eea9d 100644 (file)
@@ -1,4 +1,6 @@
+// run-rustfix
 #![warn(clippy::all, clippy::pedantic)]
+#![allow(clippy::iter_cloned_collect)]
 #![allow(clippy::missing_docs_in_private_items)]
 
 fn main() {
index 56b1f67bac962f81c766816f04081777e50bf2c9..63889055aa0e9dab2846753502736ea973b812e5 100644 (file)
@@ -1,5 +1,5 @@
 error: You are using an explicit closure for cloning elements
-  --> $DIR/map_clone.rs:5:22
+  --> $DIR/map_clone.rs:7:22
    |
 LL |     let _: Vec<i8> = vec![5_i8; 6].iter().map(|x| *x).collect();
    |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: Consider calling the dedicated `cloned` method: `vec![5_i8; 6].iter().cloned()`
@@ -7,13 +7,13 @@ LL |     let _: Vec<i8> = vec![5_i8; 6].iter().map(|x| *x).collect();
    = note: `-D clippy::map-clone` implied by `-D warnings`
 
 error: You are using an explicit closure for cloning elements
-  --> $DIR/map_clone.rs:6:26
+  --> $DIR/map_clone.rs:8:26
    |
 LL |     let _: Vec<String> = vec![String::new()].iter().map(|x| x.clone()).collect();
    |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: Consider calling the dedicated `cloned` method: `vec![String::new()].iter().cloned()`
 
 error: You are using an explicit closure for cloning elements
-  --> $DIR/map_clone.rs:7:23
+  --> $DIR/map_clone.rs:9:23
    |
 LL |     let _: Vec<u32> = vec![42, 43].iter().map(|&x| x).collect();
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: Consider calling the dedicated `cloned` method: `vec![42, 43].iter().cloned()`