]> git.lizzy.rs Git - rust.git/blob - tests/ui/rc_clone_in_vec_init/arc.stderr
fix review comments
[rust.git] / tests / ui / rc_clone_in_vec_init / arc.stderr
1 error: calling `Arc::new` in `vec![elem; len]`
2   --> $DIR/arc.rs:7:13
3    |
4 LL |     let v = vec![Arc::new("x".to_string()); 2];
5    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6    |
7    = note: `-D clippy::rc-clone-in-vec-init` implied by `-D warnings`
8    = note: each element will point to the same `Arc` instance
9 help: consider initializing each `Arc` element individually
10    |
11 LL ~     let v = {
12 LL +         let mut v = Vec::with_capacity(2);
13 LL +         (0..2).for_each(|_| v.push(Arc::new("x".to_string())));
14 LL +         v
15 LL ~     };
16    |
17 help: or if this is intentional, consider extracting the `Arc` initialization to a variable
18    |
19 LL ~     let v = {
20 LL +         let data = Arc::new("x".to_string());
21 LL +         vec![data; 2]
22 LL ~     };
23    |
24
25 error: calling `Arc::new` in `vec![elem; len]`
26   --> $DIR/arc.rs:11:13
27    |
28 LL |       let v = vec![
29    |  _____________^
30 LL | |         std::sync::Arc::new(Mutex::new({
31 LL | |             let x = 1;
32 LL | |             dbg!(x);
33 ...  |
34 LL | |         2
35 LL | |     ];
36    | |_____^
37    |
38    = note: each element will point to the same `Arc` instance
39 help: consider initializing each `Arc` element individually
40    |
41 LL ~     let v = {
42 LL +         let mut v = Vec::with_capacity(2);
43 LL +         (0..2).for_each(|_| v.push(std::sync::Arc::new(..)));
44 LL +         v
45 LL ~     };
46    |
47 help: or if this is intentional, consider extracting the `Arc` initialization to a variable
48    |
49 LL ~     let v = {
50 LL +         let data = std::sync::Arc::new(..);
51 LL +         vec![data; 2]
52 LL ~     };
53    |
54
55 error: calling `Arc::new` in `vec![elem; len]`
56   --> $DIR/arc.rs:20:14
57    |
58 LL |       let v1 = vec![
59    |  ______________^
60 LL | |         Arc::new(Mutex::new({
61 LL | |             let x = 1;
62 LL | |             dbg!(x);
63 ...  |
64 LL | |         2
65 LL | |     ];
66    | |_____^
67    |
68    = note: each element will point to the same `Arc` instance
69 help: consider initializing each `Arc` element individually
70    |
71 LL ~     let v1 = {
72 LL +         let mut v = Vec::with_capacity(2);
73 LL +         (0..2).for_each(|_| v.push(Arc::new(..)));
74 LL +         v
75 LL ~     };
76    |
77 help: or if this is intentional, consider extracting the `Arc` initialization to a variable
78    |
79 LL ~     let v1 = {
80 LL +         let data = Arc::new(..);
81 LL +         vec![data; 2]
82 LL ~     };
83    |
84
85 error: aborting due to 3 previous errors
86