2022-05-08 19:20:25 +00:00
|
|
|
error: calling `Rc::new` in `vec![elem; len]`
|
|
|
|
--> $DIR/rc.rs:8:13
|
|
|
|
|
|
|
|
|
LL | let v = vec![Rc::new("x".to_string()); 2];
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
|
= note: `-D clippy::rc-clone-in-vec-init` implied by `-D warnings`
|
|
|
|
= note: each element will point to the same `Rc` instance
|
2022-05-10 21:46:20 +00:00
|
|
|
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(Rc::new("x".to_string())));
|
|
|
|
LL + v
|
|
|
|
LL ~ };
|
|
|
|
|
|
|
|
|
help: or if this is intentional, consider extracting the `Rc` initialization to a variable
|
|
|
|
|
|
|
|
|
LL ~ let v = {
|
|
|
|
LL + let data = Rc::new("x".to_string());
|
|
|
|
LL + vec![data; 2]
|
|
|
|
LL ~ };
|
|
|
|
|
|
2022-05-08 19:20:25 +00:00
|
|
|
|
|
|
|
error: calling `Rc::new` in `vec![elem; len]`
|
|
|
|
--> $DIR/rc.rs:12:13
|
|
|
|
|
|
|
|
|
LL | let v = vec![
|
|
|
|
| _____________^
|
|
|
|
LL | | std::rc::Rc::new(Mutex::new({
|
|
|
|
LL | | let x = 1;
|
|
|
|
LL | | dbg!(x);
|
|
|
|
... |
|
|
|
|
LL | | 2
|
|
|
|
LL | | ];
|
|
|
|
| |_____^
|
|
|
|
|
|
|
|
|
= note: each element will point to the same `Rc` instance
|
2022-05-10 21:46:20 +00:00
|
|
|
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-05-08 19:20:25 +00:00
|
|
|
|
|
|
|
error: aborting due to 2 previous errors
|
|
|
|
|