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