2022-06-04 06:34:07 -05:00
|
|
|
error: initializing a reference-counted pointer in `vec![elem; len]`
|
2024-02-17 06:16:29 -06:00
|
|
|
--> tests/ui/rc_clone_in_vec_init/rc.rs:10:13
|
2022-05-21 06:24:00 -05:00
|
|
|
|
|
|
|
|
LL | let v = vec![Rc::new("x".to_string()); 2];
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
|
= note: each element will point to the same `Rc` instance
|
2022-09-22 11:04:22 -05:00
|
|
|
= note: `-D clippy::rc-clone-in-vec-init` implied by `-D warnings`
|
2023-08-01 07:02:21 -05:00
|
|
|
= help: to override `-D warnings` add `#[allow(clippy::rc_clone_in_vec_init)]`
|
2022-05-21 06:24:00 -05:00
|
|
|
help: consider initializing each `Rc` element individually
|
|
|
|
|
|
|
|
|
LL ~ let v = {
|
|
|
|
LL + let mut v = Vec::with_capacity(2);
|
2022-06-04 06:34:07 -05:00
|
|
|
LL + (0..2).for_each(|_| v.push(Rc::new(..)));
|
2022-05-21 06:24:00 -05:00
|
|
|
LL + v
|
|
|
|
LL ~ };
|
|
|
|
|
|
|
|
|
help: or if this is intentional, consider extracting the `Rc` initialization to a variable
|
|
|
|
|
|
|
|
|
LL ~ let v = {
|
2022-06-04 06:34:07 -05:00
|
|
|
LL + let data = Rc::new(..);
|
2022-05-21 06:24:00 -05:00
|
|
|
LL + vec![data; 2]
|
|
|
|
LL ~ };
|
|
|
|
|
|
|
|
|
|
2022-06-04 06:34:07 -05:00
|
|
|
error: initializing a reference-counted pointer in `vec![elem; len]`
|
2024-02-17 06:16:29 -06:00
|
|
|
--> tests/ui/rc_clone_in_vec_init/rc.rs:20:21
|
2022-05-21 06:24:00 -05:00
|
|
|
|
|
|
|
|
LL | let v = vec![Rc::new("x".to_string()); 2];
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
|
= note: each element will point to the same `Rc` instance
|
|
|
|
help: consider initializing each `Rc` element individually
|
|
|
|
|
|
|
|
|
LL ~ let v = {
|
|
|
|
LL + let mut v = Vec::with_capacity(2);
|
2022-06-04 06:34:07 -05:00
|
|
|
LL + (0..2).for_each(|_| v.push(Rc::new(..)));
|
2022-05-21 06:24:00 -05:00
|
|
|
LL + v
|
|
|
|
LL ~ };
|
|
|
|
|
|
|
|
|
help: or if this is intentional, consider extracting the `Rc` initialization to a variable
|
|
|
|
|
|
|
|
|
LL ~ let v = {
|
2022-06-04 06:34:07 -05:00
|
|
|
LL + let data = Rc::new(..);
|
2022-05-21 06:24:00 -05:00
|
|
|
LL + vec![data; 2]
|
|
|
|
LL ~ };
|
|
|
|
|
|
|
|
|
|
2022-06-04 06:34:07 -05:00
|
|
|
error: initializing a reference-counted pointer in `vec![elem; len]`
|
2024-02-17 06:16:29 -06:00
|
|
|
--> tests/ui/rc_clone_in_vec_init/rc.rs:28:13
|
2022-05-21 06:24:00 -05:00
|
|
|
|
|
|
|
|
LL | let v = vec![
|
|
|
|
| _____________^
|
2023-08-24 14:32:12 -05:00
|
|
|
LL | |
|
|
|
|
LL | |
|
2022-05-21 06:24:00 -05:00
|
|
|
LL | | std::rc::Rc::new(Mutex::new({
|
|
|
|
... |
|
|
|
|
LL | | 2
|
|
|
|
LL | | ];
|
|
|
|
| |_____^
|
|
|
|
|
|
|
|
|
= note: each element will point to the same `Rc` instance
|
|
|
|
help: consider initializing each `Rc` element individually
|
|
|
|
|
|
|
|
|
LL ~ let v = {
|
|
|
|
LL + let mut v = Vec::with_capacity(2);
|
|
|
|
LL + (0..2).for_each(|_| v.push(std::rc::Rc::new(..)));
|
|
|
|
LL + v
|
|
|
|
LL ~ };
|
|
|
|
|
|
|
|
|
help: or if this is intentional, consider extracting the `Rc` initialization to a variable
|
|
|
|
|
|
|
|
|
LL ~ let v = {
|
|
|
|
LL + let data = std::rc::Rc::new(..);
|
|
|
|
LL + vec![data; 2]
|
|
|
|
LL ~ };
|
|
|
|
|
|
|
|
|
|
2022-06-04 06:34:07 -05:00
|
|
|
error: initializing a reference-counted pointer in `vec![elem; len]`
|
2024-02-17 06:16:29 -06:00
|
|
|
--> tests/ui/rc_clone_in_vec_init/rc.rs:39:14
|
2022-05-21 06:24:00 -05:00
|
|
|
|
|
|
|
|
LL | let v1 = vec![
|
|
|
|
| ______________^
|
2023-08-24 14:32:12 -05:00
|
|
|
LL | |
|
|
|
|
LL | |
|
2022-05-21 06:24:00 -05:00
|
|
|
LL | | Rc::new(Mutex::new({
|
|
|
|
... |
|
|
|
|
LL | | 2
|
|
|
|
LL | | ];
|
|
|
|
| |_____^
|
|
|
|
|
|
|
|
|
= note: each element will point to the same `Rc` instance
|
|
|
|
help: consider initializing each `Rc` element individually
|
|
|
|
|
|
|
|
|
LL ~ let v1 = {
|
|
|
|
LL + let mut v = Vec::with_capacity(2);
|
|
|
|
LL + (0..2).for_each(|_| v.push(Rc::new(..)));
|
|
|
|
LL + v
|
|
|
|
LL ~ };
|
|
|
|
|
|
|
|
|
help: or if this is intentional, consider extracting the `Rc` initialization to a variable
|
|
|
|
|
|
|
|
|
LL ~ let v1 = {
|
|
|
|
LL + let data = Rc::new(..);
|
|
|
|
LL + vec![data; 2]
|
|
|
|
LL ~ };
|
|
|
|
|
|
|
|
|
|
|
|
|
error: aborting due to 4 previous errors
|
|
|
|
|