]> git.lizzy.rs Git - rust.git/blob - tests/ui/unnecessary_clone.stderr
Auto merge of #3635 - matthiaskrgr:revert_random_state_3603, r=xfix
[rust.git] / tests / ui / unnecessary_clone.stderr
1 error: using `clone` on a `Copy` type
2   --> $DIR/unnecessary_clone.rs:26:5
3    |
4 LL |     42.clone();
5    |     ^^^^^^^^^^ help: try removing the `clone` call: `42`
6    |
7    = note: `-D clippy::clone-on-copy` implied by `-D warnings`
8
9 error: using `clone` on a `Copy` type
10   --> $DIR/unnecessary_clone.rs:30:5
11    |
12 LL |     (&42).clone();
13    |     ^^^^^^^^^^^^^ help: try dereferencing it: `*(&42)`
14
15 error: using `clone` on a `Copy` type
16   --> $DIR/unnecessary_clone.rs:33:5
17    |
18 LL |     rc.borrow().clone();
19    |     ^^^^^^^^^^^^^^^^^^^ help: try dereferencing it: `*rc.borrow()`
20
21 error: using '.clone()' on a ref-counted pointer
22   --> $DIR/unnecessary_clone.rs:43:5
23    |
24 LL |     rc.clone();
25    |     ^^^^^^^^^^ help: try this: `Rc::<bool>::clone(&rc)`
26    |
27    = note: `-D clippy::clone-on-ref-ptr` implied by `-D warnings`
28
29 error: using '.clone()' on a ref-counted pointer
30   --> $DIR/unnecessary_clone.rs:46:5
31    |
32 LL |     arc.clone();
33    |     ^^^^^^^^^^^ help: try this: `Arc::<bool>::clone(&arc)`
34
35 error: using '.clone()' on a ref-counted pointer
36   --> $DIR/unnecessary_clone.rs:49:5
37    |
38 LL |     rcweak.clone();
39    |     ^^^^^^^^^^^^^^ help: try this: `Weak::<bool>::clone(&rcweak)`
40
41 error: using '.clone()' on a ref-counted pointer
42   --> $DIR/unnecessary_clone.rs:52:5
43    |
44 LL |     arc_weak.clone();
45    |     ^^^^^^^^^^^^^^^^ help: try this: `Weak::<bool>::clone(&arc_weak)`
46
47 error: using '.clone()' on a ref-counted pointer
48   --> $DIR/unnecessary_clone.rs:56:29
49    |
50 LL |     let _: Arc<SomeTrait> = x.clone();
51    |                             ^^^^^^^^^ help: try this: `Arc::<SomeImpl>::clone(&x)`
52
53 error: using `clone` on a `Copy` type
54   --> $DIR/unnecessary_clone.rs:60:5
55    |
56 LL |     t.clone();
57    |     ^^^^^^^^^ help: try removing the `clone` call: `t`
58
59 error: using `clone` on a `Copy` type
60   --> $DIR/unnecessary_clone.rs:62:5
61    |
62 LL |     Some(t).clone();
63    |     ^^^^^^^^^^^^^^^ help: try removing the `clone` call: `Some(t)`
64
65 error: using `clone` on a double-reference; this will copy the reference instead of cloning the inner type
66   --> $DIR/unnecessary_clone.rs:68:22
67    |
68 LL |     let z: &Vec<_> = y.clone();
69    |                      ^^^^^^^^^
70    |
71    = note: #[deny(clippy::clone_double_ref)] on by default
72 help: try dereferencing it
73    |
74 LL |     let z: &Vec<_> = &(*y).clone();
75    |                      ^^^^^^^^^^^^^
76 help: or try being explicit about what type to clone
77    |
78 LL |     let z: &Vec<_> = &std::vec::Vec<i32>::clone(y);
79    |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
80
81 error: called `cloned().collect()` on a slice to create a `Vec`. Calling `to_vec()` is both faster and more readable
82   --> $DIR/unnecessary_clone.rs:75:26
83    |
84 LL |     let v2: Vec<isize> = v.iter().cloned().collect();
85    |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
86    |
87    = note: `-D clippy::iter-cloned-collect` implied by `-D warnings`
88
89 error: using `clone` on a `Copy` type
90   --> $DIR/unnecessary_clone.rs:111:20
91    |
92 LL |         let _: E = a.clone();
93    |                    ^^^^^^^^^ help: try dereferencing it: `*****a`
94
95 error: aborting due to 13 previous errors
96