1
1
error: you are using an explicit closure for copying elements
2
- --> $DIR/map_clone.rs:11 :22
2
+ --> $DIR/map_clone.rs:12 :22
3
3
|
4
4
LL | let _: Vec<i8> = vec![5_i8; 6].iter().map(|x| *x).collect();
5
5
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `copied` method: `vec![5_i8; 6].iter().copied()`
@@ -8,34 +8,40 @@ LL | let _: Vec<i8> = vec![5_i8; 6].iter().map(|x| *x).collect();
8
8
= help: to override `-D warnings` add `#[allow(clippy::map_clone)]`
9
9
10
10
error: you are using an explicit closure for cloning elements
11
- --> $DIR/map_clone.rs:12 :26
11
+ --> $DIR/map_clone.rs:13 :26
12
12
|
13
13
LL | let _: Vec<String> = vec![String::new()].iter().map(|x| x.clone()).collect();
14
14
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `cloned` method: `vec![String::new()].iter().cloned()`
15
15
16
16
error: you are using an explicit closure for copying elements
17
- --> $DIR/map_clone.rs:13 :23
17
+ --> $DIR/map_clone.rs:14 :23
18
18
|
19
19
LL | let _: Vec<u32> = vec![42, 43].iter().map(|&x| x).collect();
20
20
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `copied` method: `vec![42, 43].iter().copied()`
21
21
22
22
error: you are using an explicit closure for copying elements
23
- --> $DIR/map_clone.rs:15 :26
23
+ --> $DIR/map_clone.rs:16 :26
24
24
|
25
25
LL | let _: Option<u64> = Some(&16).map(|b| *b);
26
26
| ^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `copied` method: `Some(&16).copied()`
27
27
28
28
error: you are using an explicit closure for copying elements
29
- --> $DIR/map_clone.rs:16 :25
29
+ --> $DIR/map_clone.rs:17 :25
30
30
|
31
31
LL | let _: Option<u8> = Some(&1).map(|x| x.clone());
32
32
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `copied` method: `Some(&1).copied()`
33
33
34
34
error: you are needlessly cloning iterator elements
35
- --> $DIR/map_clone.rs:27 :29
35
+ --> $DIR/map_clone.rs:28 :29
36
36
|
37
37
LL | let _ = std::env::args().map(|v| v.clone());
38
38
| ^^^^^^^^^^^^^^^^^^^ help: remove the `map` call
39
39
40
- error: aborting due to 6 previous errors
40
+ error: you are explicitly cloning with `.map()`
41
+ --> $DIR/map_clone.rs:66:13
42
+ |
43
+ LL | let y = x.as_ref().map(|x| String::clone(x));
44
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `cloned` method: `x.as_ref().cloned()`
45
+
46
+ error: aborting due to 7 previous errors
41
47
0 commit comments