mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 05:03:21 +00:00
Add run-rustfix to map_clone test
This commit is contained in:
parent
fb90fcb610
commit
9ff821a7e8
3 changed files with 16 additions and 3 deletions
11
tests/ui/map_clone.fixed
Normal file
11
tests/ui/map_clone.fixed
Normal file
|
@ -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);
|
||||
}
|
|
@ -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() {
|
||||
|
|
|
@ -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()`
|
||||
|
|
Loading…
Reference in a new issue