2
0
Fork 0
mirror of https://github.com/rust-lang/rust-clippy synced 2024-12-26 04:53:31 +00:00
rust-clippy/tests/ui/rc_clone_in_vec_init/rc.stderr

57 lines
1.5 KiB
Text
Raw Normal View History

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
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
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