rust-clippy/tests/ui/rc_clone_in_vec_init/rc.stderr
2022-05-11 01:09:45 +03:00

56 lines
1.5 KiB
Text

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
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 ~ };
|
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
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 ~ };
|
error: aborting due to 2 previous errors