Account for move error in the spread operator on struct literals
We attempt to suggest an appropriate clone for move errors on expressions
like `S { ..s }` where a field isn't `Copy`. If we can't suggest, we still don't
emit the incorrect suggestion of `S { ..s }.clone()`.
```
error[E0509]: cannot move out of type `S<K>`, which implements the `Drop` trait
--> $DIR/borrowck-struct-update-with-dtor.rs:28:19
|
LL | let _s2 = S { a: 2, ..s0 };
| ^^^^^^^^^^^^^^^^
| |
| cannot move out of here
| move occurs because `s0.c` has type `K`, which does not implement the `Copy` trait
|
help: clone the value from the field instead of using the spread operator syntax
|
LL | let _s2 = S { a: 2, c: s0.c.clone(), ..s0 };
| +++++++++++++++++
```
```
error[E0509]: cannot move out of type `S<()>`, which implements the `Drop` trait
--> $DIR/borrowck-struct-update-with-dtor.rs:20:19
|
LL | let _s2 = S { a: 2, ..s0 };
| ^^^^^^^^^^^^^^^^
| |
| cannot move out of here
| move occurs because `s0.b` has type `B`, which does not implement the `Copy` trait
|
note: `B` doesn't implement `Copy` or `Clone`
--> $DIR/borrowck-struct-update-with-dtor.rs:4:1
|
LL | struct B;
| ^^^^^^^^
help: if `B` implemented `Clone`, you could clone the value from the field instead of using the spread operator syntax
|
LL | let _s2 = S { a: 2, b: s0.b.clone(), ..s0 };
| +++++++++++++++++
```
2024-03-16 18:19:17 +00:00
|
|
|
error[E0509]: cannot move out of type `S<()>`, which implements the `Drop` trait
|
|
|
|
--> $DIR/borrowck-struct-update-with-dtor.rs:20:19
|
2018-08-08 14:28:26 +02:00
|
|
|
|
|
Account for move error in the spread operator on struct literals
We attempt to suggest an appropriate clone for move errors on expressions
like `S { ..s }` where a field isn't `Copy`. If we can't suggest, we still don't
emit the incorrect suggestion of `S { ..s }.clone()`.
```
error[E0509]: cannot move out of type `S<K>`, which implements the `Drop` trait
--> $DIR/borrowck-struct-update-with-dtor.rs:28:19
|
LL | let _s2 = S { a: 2, ..s0 };
| ^^^^^^^^^^^^^^^^
| |
| cannot move out of here
| move occurs because `s0.c` has type `K`, which does not implement the `Copy` trait
|
help: clone the value from the field instead of using the spread operator syntax
|
LL | let _s2 = S { a: 2, c: s0.c.clone(), ..s0 };
| +++++++++++++++++
```
```
error[E0509]: cannot move out of type `S<()>`, which implements the `Drop` trait
--> $DIR/borrowck-struct-update-with-dtor.rs:20:19
|
LL | let _s2 = S { a: 2, ..s0 };
| ^^^^^^^^^^^^^^^^
| |
| cannot move out of here
| move occurs because `s0.b` has type `B`, which does not implement the `Copy` trait
|
note: `B` doesn't implement `Copy` or `Clone`
--> $DIR/borrowck-struct-update-with-dtor.rs:4:1
|
LL | struct B;
| ^^^^^^^^
help: if `B` implemented `Clone`, you could clone the value from the field instead of using the spread operator syntax
|
LL | let _s2 = S { a: 2, b: s0.b.clone(), ..s0 };
| +++++++++++++++++
```
2024-03-16 18:19:17 +00:00
|
|
|
LL | let _s2 = S { a: 2, ..s0 };
|
|
|
|
| ^^^^^^^^^^^^^^^^
|
|
|
|
| |
|
|
|
|
| cannot move out of here
|
|
|
|
| move occurs because `s0.b` has type `B`, which does not implement the `Copy` trait
|
|
|
|
|
|
|
|
|
note: `B` doesn't implement `Copy` or `Clone`
|
|
|
|
--> $DIR/borrowck-struct-update-with-dtor.rs:4:1
|
|
|
|
|
|
|
|
|
LL | struct B;
|
|
|
|
| ^^^^^^^^
|
2024-04-12 20:57:07 +00:00
|
|
|
help: if `B` implemented `Clone`, you could clone the value from the field instead of using the functional record update syntax
|
Account for move error in the spread operator on struct literals
We attempt to suggest an appropriate clone for move errors on expressions
like `S { ..s }` where a field isn't `Copy`. If we can't suggest, we still don't
emit the incorrect suggestion of `S { ..s }.clone()`.
```
error[E0509]: cannot move out of type `S<K>`, which implements the `Drop` trait
--> $DIR/borrowck-struct-update-with-dtor.rs:28:19
|
LL | let _s2 = S { a: 2, ..s0 };
| ^^^^^^^^^^^^^^^^
| |
| cannot move out of here
| move occurs because `s0.c` has type `K`, which does not implement the `Copy` trait
|
help: clone the value from the field instead of using the spread operator syntax
|
LL | let _s2 = S { a: 2, c: s0.c.clone(), ..s0 };
| +++++++++++++++++
```
```
error[E0509]: cannot move out of type `S<()>`, which implements the `Drop` trait
--> $DIR/borrowck-struct-update-with-dtor.rs:20:19
|
LL | let _s2 = S { a: 2, ..s0 };
| ^^^^^^^^^^^^^^^^
| |
| cannot move out of here
| move occurs because `s0.b` has type `B`, which does not implement the `Copy` trait
|
note: `B` doesn't implement `Copy` or `Clone`
--> $DIR/borrowck-struct-update-with-dtor.rs:4:1
|
LL | struct B;
| ^^^^^^^^
help: if `B` implemented `Clone`, you could clone the value from the field instead of using the spread operator syntax
|
LL | let _s2 = S { a: 2, b: s0.b.clone(), ..s0 };
| +++++++++++++++++
```
2024-03-16 18:19:17 +00:00
|
|
|
|
|
|
|
|
LL | let _s2 = S { a: 2, b: s0.b.clone(), ..s0 };
|
|
|
|
| +++++++++++++++++
|
|
|
|
|
|
|
|
error[E0509]: cannot move out of type `S<B>`, which implements the `Drop` trait
|
|
|
|
--> $DIR/borrowck-struct-update-with-dtor.rs:24:19
|
|
|
|
|
|
|
|
|
LL | let _s2 = S { a: 2, ..s0 };
|
|
|
|
| ^^^^^^^^^^^^^^^^
|
|
|
|
| |
|
|
|
|
| cannot move out of here
|
|
|
|
| move occurs because `s0.b` has type `B`, which does not implement the `Copy` trait
|
|
|
|
|
|
|
|
|
note: `B` doesn't implement `Copy` or `Clone`
|
|
|
|
--> $DIR/borrowck-struct-update-with-dtor.rs:4:1
|
|
|
|
|
|
|
|
|
LL | struct B;
|
|
|
|
| ^^^^^^^^
|
2024-04-12 20:57:07 +00:00
|
|
|
help: if `B` implemented `Clone`, you could clone the value from the field instead of using the functional record update syntax
|
Account for move error in the spread operator on struct literals
We attempt to suggest an appropriate clone for move errors on expressions
like `S { ..s }` where a field isn't `Copy`. If we can't suggest, we still don't
emit the incorrect suggestion of `S { ..s }.clone()`.
```
error[E0509]: cannot move out of type `S<K>`, which implements the `Drop` trait
--> $DIR/borrowck-struct-update-with-dtor.rs:28:19
|
LL | let _s2 = S { a: 2, ..s0 };
| ^^^^^^^^^^^^^^^^
| |
| cannot move out of here
| move occurs because `s0.c` has type `K`, which does not implement the `Copy` trait
|
help: clone the value from the field instead of using the spread operator syntax
|
LL | let _s2 = S { a: 2, c: s0.c.clone(), ..s0 };
| +++++++++++++++++
```
```
error[E0509]: cannot move out of type `S<()>`, which implements the `Drop` trait
--> $DIR/borrowck-struct-update-with-dtor.rs:20:19
|
LL | let _s2 = S { a: 2, ..s0 };
| ^^^^^^^^^^^^^^^^
| |
| cannot move out of here
| move occurs because `s0.b` has type `B`, which does not implement the `Copy` trait
|
note: `B` doesn't implement `Copy` or `Clone`
--> $DIR/borrowck-struct-update-with-dtor.rs:4:1
|
LL | struct B;
| ^^^^^^^^
help: if `B` implemented `Clone`, you could clone the value from the field instead of using the spread operator syntax
|
LL | let _s2 = S { a: 2, b: s0.b.clone(), ..s0 };
| +++++++++++++++++
```
2024-03-16 18:19:17 +00:00
|
|
|
|
|
|
|
|
LL | let _s2 = S { a: 2, b: s0.b.clone(), c: s0.c.clone() };
|
|
|
|
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
error[E0509]: cannot move out of type `S<B>`, which implements the `Drop` trait
|
|
|
|
--> $DIR/borrowck-struct-update-with-dtor.rs:24:19
|
|
|
|
|
|
|
|
|
LL | let _s2 = S { a: 2, ..s0 };
|
|
|
|
| ^^^^^^^^^^^^^^^^
|
|
|
|
| |
|
|
|
|
| cannot move out of here
|
|
|
|
| move occurs because `s0.c` has type `B`, which does not implement the `Copy` trait
|
|
|
|
|
|
|
|
|
note: `B` doesn't implement `Copy` or `Clone`
|
|
|
|
--> $DIR/borrowck-struct-update-with-dtor.rs:4:1
|
|
|
|
|
|
|
|
|
LL | struct B;
|
|
|
|
| ^^^^^^^^
|
2024-04-12 20:57:07 +00:00
|
|
|
help: if `B` implemented `Clone`, you could clone the value from the field instead of using the functional record update syntax
|
Account for move error in the spread operator on struct literals
We attempt to suggest an appropriate clone for move errors on expressions
like `S { ..s }` where a field isn't `Copy`. If we can't suggest, we still don't
emit the incorrect suggestion of `S { ..s }.clone()`.
```
error[E0509]: cannot move out of type `S<K>`, which implements the `Drop` trait
--> $DIR/borrowck-struct-update-with-dtor.rs:28:19
|
LL | let _s2 = S { a: 2, ..s0 };
| ^^^^^^^^^^^^^^^^
| |
| cannot move out of here
| move occurs because `s0.c` has type `K`, which does not implement the `Copy` trait
|
help: clone the value from the field instead of using the spread operator syntax
|
LL | let _s2 = S { a: 2, c: s0.c.clone(), ..s0 };
| +++++++++++++++++
```
```
error[E0509]: cannot move out of type `S<()>`, which implements the `Drop` trait
--> $DIR/borrowck-struct-update-with-dtor.rs:20:19
|
LL | let _s2 = S { a: 2, ..s0 };
| ^^^^^^^^^^^^^^^^
| |
| cannot move out of here
| move occurs because `s0.b` has type `B`, which does not implement the `Copy` trait
|
note: `B` doesn't implement `Copy` or `Clone`
--> $DIR/borrowck-struct-update-with-dtor.rs:4:1
|
LL | struct B;
| ^^^^^^^^
help: if `B` implemented `Clone`, you could clone the value from the field instead of using the spread operator syntax
|
LL | let _s2 = S { a: 2, b: s0.b.clone(), ..s0 };
| +++++++++++++++++
```
2024-03-16 18:19:17 +00:00
|
|
|
|
|
|
|
|
LL | let _s2 = S { a: 2, b: s0.b.clone(), c: s0.c.clone() };
|
|
|
|
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
error[E0509]: cannot move out of type `S<K>`, which implements the `Drop` trait
|
|
|
|
--> $DIR/borrowck-struct-update-with-dtor.rs:29:19
|
|
|
|
|
|
|
|
|
LL | let _s2 = S { a: 2, ..s0 };
|
|
|
|
| ^^^^^^^^^^^^^^^^
|
|
|
|
| |
|
|
|
|
| cannot move out of here
|
|
|
|
| move occurs because `s0.b` has type `B`, which does not implement the `Copy` trait
|
|
|
|
|
|
|
|
|
note: `B` doesn't implement `Copy` or `Clone`
|
|
|
|
--> $DIR/borrowck-struct-update-with-dtor.rs:4:1
|
|
|
|
|
|
|
|
|
LL | struct B;
|
|
|
|
| ^^^^^^^^
|
2024-04-12 20:57:07 +00:00
|
|
|
help: if `B` implemented `Clone`, you could clone the value from the field instead of using the functional record update syntax
|
Account for move error in the spread operator on struct literals
We attempt to suggest an appropriate clone for move errors on expressions
like `S { ..s }` where a field isn't `Copy`. If we can't suggest, we still don't
emit the incorrect suggestion of `S { ..s }.clone()`.
```
error[E0509]: cannot move out of type `S<K>`, which implements the `Drop` trait
--> $DIR/borrowck-struct-update-with-dtor.rs:28:19
|
LL | let _s2 = S { a: 2, ..s0 };
| ^^^^^^^^^^^^^^^^
| |
| cannot move out of here
| move occurs because `s0.c` has type `K`, which does not implement the `Copy` trait
|
help: clone the value from the field instead of using the spread operator syntax
|
LL | let _s2 = S { a: 2, c: s0.c.clone(), ..s0 };
| +++++++++++++++++
```
```
error[E0509]: cannot move out of type `S<()>`, which implements the `Drop` trait
--> $DIR/borrowck-struct-update-with-dtor.rs:20:19
|
LL | let _s2 = S { a: 2, ..s0 };
| ^^^^^^^^^^^^^^^^
| |
| cannot move out of here
| move occurs because `s0.b` has type `B`, which does not implement the `Copy` trait
|
note: `B` doesn't implement `Copy` or `Clone`
--> $DIR/borrowck-struct-update-with-dtor.rs:4:1
|
LL | struct B;
| ^^^^^^^^
help: if `B` implemented `Clone`, you could clone the value from the field instead of using the spread operator syntax
|
LL | let _s2 = S { a: 2, b: s0.b.clone(), ..s0 };
| +++++++++++++++++
```
2024-03-16 18:19:17 +00:00
|
|
|
|
|
|
|
|
LL | let _s2 = S { a: 2, b: s0.b.clone(), ..s0 };
|
|
|
|
| +++++++++++++++++
|
|
|
|
|
|
|
|
error[E0509]: cannot move out of type `S<K>`, which implements the `Drop` trait
|
|
|
|
--> $DIR/borrowck-struct-update-with-dtor.rs:29:19
|
|
|
|
|
|
|
|
|
LL | let _s2 = S { a: 2, ..s0 };
|
|
|
|
| ^^^^^^^^^^^^^^^^
|
|
|
|
| |
|
|
|
|
| cannot move out of here
|
|
|
|
| move occurs because `s0.c` has type `K`, which does not implement the `Copy` trait
|
|
|
|
|
|
2024-04-12 20:57:07 +00:00
|
|
|
help: clone the value from the field instead of using the functional record update syntax
|
Account for move error in the spread operator on struct literals
We attempt to suggest an appropriate clone for move errors on expressions
like `S { ..s }` where a field isn't `Copy`. If we can't suggest, we still don't
emit the incorrect suggestion of `S { ..s }.clone()`.
```
error[E0509]: cannot move out of type `S<K>`, which implements the `Drop` trait
--> $DIR/borrowck-struct-update-with-dtor.rs:28:19
|
LL | let _s2 = S { a: 2, ..s0 };
| ^^^^^^^^^^^^^^^^
| |
| cannot move out of here
| move occurs because `s0.c` has type `K`, which does not implement the `Copy` trait
|
help: clone the value from the field instead of using the spread operator syntax
|
LL | let _s2 = S { a: 2, c: s0.c.clone(), ..s0 };
| +++++++++++++++++
```
```
error[E0509]: cannot move out of type `S<()>`, which implements the `Drop` trait
--> $DIR/borrowck-struct-update-with-dtor.rs:20:19
|
LL | let _s2 = S { a: 2, ..s0 };
| ^^^^^^^^^^^^^^^^
| |
| cannot move out of here
| move occurs because `s0.b` has type `B`, which does not implement the `Copy` trait
|
note: `B` doesn't implement `Copy` or `Clone`
--> $DIR/borrowck-struct-update-with-dtor.rs:4:1
|
LL | struct B;
| ^^^^^^^^
help: if `B` implemented `Clone`, you could clone the value from the field instead of using the spread operator syntax
|
LL | let _s2 = S { a: 2, b: s0.b.clone(), ..s0 };
| +++++++++++++++++
```
2024-03-16 18:19:17 +00:00
|
|
|
|
|
|
|
|
LL | let _s2 = S { a: 2, c: s0.c.clone(), ..s0 };
|
|
|
|
| +++++++++++++++++
|
|
|
|
|
|
|
|
error[E0509]: cannot move out of type `T`, which implements the `Drop` trait
|
|
|
|
--> $DIR/borrowck-struct-update-with-dtor.rs:37:19
|
|
|
|
|
|
|
|
|
LL | let _s2 = T { a: 2, ..s0 };
|
|
|
|
| ^^^^^^^^^^^^^^^^
|
|
|
|
| |
|
|
|
|
| cannot move out of here
|
|
|
|
| move occurs because `s0.b` has type `Box<isize>`, which does not implement the `Copy` trait
|
|
|
|
|
|
2024-04-12 20:57:07 +00:00
|
|
|
help: clone the value from the field instead of using the functional record update syntax
|
Account for move error in the spread operator on struct literals
We attempt to suggest an appropriate clone for move errors on expressions
like `S { ..s }` where a field isn't `Copy`. If we can't suggest, we still don't
emit the incorrect suggestion of `S { ..s }.clone()`.
```
error[E0509]: cannot move out of type `S<K>`, which implements the `Drop` trait
--> $DIR/borrowck-struct-update-with-dtor.rs:28:19
|
LL | let _s2 = S { a: 2, ..s0 };
| ^^^^^^^^^^^^^^^^
| |
| cannot move out of here
| move occurs because `s0.c` has type `K`, which does not implement the `Copy` trait
|
help: clone the value from the field instead of using the spread operator syntax
|
LL | let _s2 = S { a: 2, c: s0.c.clone(), ..s0 };
| +++++++++++++++++
```
```
error[E0509]: cannot move out of type `S<()>`, which implements the `Drop` trait
--> $DIR/borrowck-struct-update-with-dtor.rs:20:19
|
LL | let _s2 = S { a: 2, ..s0 };
| ^^^^^^^^^^^^^^^^
| |
| cannot move out of here
| move occurs because `s0.b` has type `B`, which does not implement the `Copy` trait
|
note: `B` doesn't implement `Copy` or `Clone`
--> $DIR/borrowck-struct-update-with-dtor.rs:4:1
|
LL | struct B;
| ^^^^^^^^
help: if `B` implemented `Clone`, you could clone the value from the field instead of using the spread operator syntax
|
LL | let _s2 = S { a: 2, b: s0.b.clone(), ..s0 };
| +++++++++++++++++
```
2024-03-16 18:19:17 +00:00
|
|
|
|
|
|
|
|
LL | let _s2 = T { a: 2, b: s0.b.clone() };
|
|
|
|
| ~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
error[E0509]: cannot move out of type `T`, which implements the `Drop` trait
|
|
|
|
--> $DIR/borrowck-struct-update-with-dtor.rs:42:19
|
|
|
|
|
|
|
|
|
LL | let _s2 = T { ..s0 };
|
|
|
|
| ^^^^^^^^^^
|
|
|
|
| |
|
|
|
|
| cannot move out of here
|
|
|
|
| move occurs because `s0.b` has type `Box<isize>`, which does not implement the `Copy` trait
|
|
|
|
|
|
2024-04-12 20:57:07 +00:00
|
|
|
help: clone the value from the field instead of using the functional record update syntax
|
Account for move error in the spread operator on struct literals
We attempt to suggest an appropriate clone for move errors on expressions
like `S { ..s }` where a field isn't `Copy`. If we can't suggest, we still don't
emit the incorrect suggestion of `S { ..s }.clone()`.
```
error[E0509]: cannot move out of type `S<K>`, which implements the `Drop` trait
--> $DIR/borrowck-struct-update-with-dtor.rs:28:19
|
LL | let _s2 = S { a: 2, ..s0 };
| ^^^^^^^^^^^^^^^^
| |
| cannot move out of here
| move occurs because `s0.c` has type `K`, which does not implement the `Copy` trait
|
help: clone the value from the field instead of using the spread operator syntax
|
LL | let _s2 = S { a: 2, c: s0.c.clone(), ..s0 };
| +++++++++++++++++
```
```
error[E0509]: cannot move out of type `S<()>`, which implements the `Drop` trait
--> $DIR/borrowck-struct-update-with-dtor.rs:20:19
|
LL | let _s2 = S { a: 2, ..s0 };
| ^^^^^^^^^^^^^^^^
| |
| cannot move out of here
| move occurs because `s0.b` has type `B`, which does not implement the `Copy` trait
|
note: `B` doesn't implement `Copy` or `Clone`
--> $DIR/borrowck-struct-update-with-dtor.rs:4:1
|
LL | struct B;
| ^^^^^^^^
help: if `B` implemented `Clone`, you could clone the value from the field instead of using the spread operator syntax
|
LL | let _s2 = S { a: 2, b: s0.b.clone(), ..s0 };
| +++++++++++++++++
```
2024-03-16 18:19:17 +00:00
|
|
|
|
|
|
|
|
LL | let _s2 = T { b: s0.b.clone(), ..s0 };
|
|
|
|
| ~~~~~~~~~~~~~~~~~~~~~~~~~
|
2018-08-08 14:28:26 +02:00
|
|
|
|
|
|
|
error[E0509]: cannot move out of type `T`, which implements the `Drop` trait
|
Account for move error in the spread operator on struct literals
We attempt to suggest an appropriate clone for move errors on expressions
like `S { ..s }` where a field isn't `Copy`. If we can't suggest, we still don't
emit the incorrect suggestion of `S { ..s }.clone()`.
```
error[E0509]: cannot move out of type `S<K>`, which implements the `Drop` trait
--> $DIR/borrowck-struct-update-with-dtor.rs:28:19
|
LL | let _s2 = S { a: 2, ..s0 };
| ^^^^^^^^^^^^^^^^
| |
| cannot move out of here
| move occurs because `s0.c` has type `K`, which does not implement the `Copy` trait
|
help: clone the value from the field instead of using the spread operator syntax
|
LL | let _s2 = S { a: 2, c: s0.c.clone(), ..s0 };
| +++++++++++++++++
```
```
error[E0509]: cannot move out of type `S<()>`, which implements the `Drop` trait
--> $DIR/borrowck-struct-update-with-dtor.rs:20:19
|
LL | let _s2 = S { a: 2, ..s0 };
| ^^^^^^^^^^^^^^^^
| |
| cannot move out of here
| move occurs because `s0.b` has type `B`, which does not implement the `Copy` trait
|
note: `B` doesn't implement `Copy` or `Clone`
--> $DIR/borrowck-struct-update-with-dtor.rs:4:1
|
LL | struct B;
| ^^^^^^^^
help: if `B` implemented `Clone`, you could clone the value from the field instead of using the spread operator syntax
|
LL | let _s2 = S { a: 2, b: s0.b.clone(), ..s0 };
| +++++++++++++++++
```
2024-03-16 18:19:17 +00:00
|
|
|
--> $DIR/borrowck-struct-update-with-dtor.rs:47:32
|
2018-08-08 14:28:26 +02:00
|
|
|
|
|
Account for move error in the spread operator on struct literals
We attempt to suggest an appropriate clone for move errors on expressions
like `S { ..s }` where a field isn't `Copy`. If we can't suggest, we still don't
emit the incorrect suggestion of `S { ..s }.clone()`.
```
error[E0509]: cannot move out of type `S<K>`, which implements the `Drop` trait
--> $DIR/borrowck-struct-update-with-dtor.rs:28:19
|
LL | let _s2 = S { a: 2, ..s0 };
| ^^^^^^^^^^^^^^^^
| |
| cannot move out of here
| move occurs because `s0.c` has type `K`, which does not implement the `Copy` trait
|
help: clone the value from the field instead of using the spread operator syntax
|
LL | let _s2 = S { a: 2, c: s0.c.clone(), ..s0 };
| +++++++++++++++++
```
```
error[E0509]: cannot move out of type `S<()>`, which implements the `Drop` trait
--> $DIR/borrowck-struct-update-with-dtor.rs:20:19
|
LL | let _s2 = S { a: 2, ..s0 };
| ^^^^^^^^^^^^^^^^
| |
| cannot move out of here
| move occurs because `s0.b` has type `B`, which does not implement the `Copy` trait
|
note: `B` doesn't implement `Copy` or `Clone`
--> $DIR/borrowck-struct-update-with-dtor.rs:4:1
|
LL | struct B;
| ^^^^^^^^
help: if `B` implemented `Clone`, you could clone the value from the field instead of using the spread operator syntax
|
LL | let _s2 = S { a: 2, b: s0.b.clone(), ..s0 };
| +++++++++++++++++
```
2024-03-16 18:19:17 +00:00
|
|
|
LL | let _s2 = T { a: 2, b: s0.b };
|
|
|
|
| ^^^^
|
|
|
|
| |
|
|
|
|
| cannot move out of here
|
|
|
|
| move occurs because `s0.b` has type `Box<isize>`, which does not implement the `Copy` trait
|
2024-03-13 03:41:41 +00:00
|
|
|
|
|
|
|
|
help: consider cloning the value if the performance cost is acceptable
|
|
|
|
|
|
Account for move error in the spread operator on struct literals
We attempt to suggest an appropriate clone for move errors on expressions
like `S { ..s }` where a field isn't `Copy`. If we can't suggest, we still don't
emit the incorrect suggestion of `S { ..s }.clone()`.
```
error[E0509]: cannot move out of type `S<K>`, which implements the `Drop` trait
--> $DIR/borrowck-struct-update-with-dtor.rs:28:19
|
LL | let _s2 = S { a: 2, ..s0 };
| ^^^^^^^^^^^^^^^^
| |
| cannot move out of here
| move occurs because `s0.c` has type `K`, which does not implement the `Copy` trait
|
help: clone the value from the field instead of using the spread operator syntax
|
LL | let _s2 = S { a: 2, c: s0.c.clone(), ..s0 };
| +++++++++++++++++
```
```
error[E0509]: cannot move out of type `S<()>`, which implements the `Drop` trait
--> $DIR/borrowck-struct-update-with-dtor.rs:20:19
|
LL | let _s2 = S { a: 2, ..s0 };
| ^^^^^^^^^^^^^^^^
| |
| cannot move out of here
| move occurs because `s0.b` has type `B`, which does not implement the `Copy` trait
|
note: `B` doesn't implement `Copy` or `Clone`
--> $DIR/borrowck-struct-update-with-dtor.rs:4:1
|
LL | struct B;
| ^^^^^^^^
help: if `B` implemented `Clone`, you could clone the value from the field instead of using the spread operator syntax
|
LL | let _s2 = S { a: 2, b: s0.b.clone(), ..s0 };
| +++++++++++++++++
```
2024-03-16 18:19:17 +00:00
|
|
|
LL | let _s2 = T { a: 2, b: s0.b.clone() };
|
|
|
|
| ++++++++
|
|
|
|
|
|
|
|
error[E0509]: cannot move out of type `V<K>`, which implements the `Drop` trait
|
|
|
|
--> $DIR/borrowck-struct-update-with-dtor.rs:52:19
|
|
|
|
|
|
|
|
|
LL | let _s2 = V { a: 2, ..s0 };
|
|
|
|
| ^^^^^^^^^^^^^^^^
|
|
|
|
| |
|
|
|
|
| cannot move out of here
|
|
|
|
| move occurs because `s0.b` has type `Box<isize>`, which does not implement the `Copy` trait
|
|
|
|
|
|
2024-04-12 20:57:07 +00:00
|
|
|
help: clone the value from the field instead of using the functional record update syntax
|
Account for move error in the spread operator on struct literals
We attempt to suggest an appropriate clone for move errors on expressions
like `S { ..s }` where a field isn't `Copy`. If we can't suggest, we still don't
emit the incorrect suggestion of `S { ..s }.clone()`.
```
error[E0509]: cannot move out of type `S<K>`, which implements the `Drop` trait
--> $DIR/borrowck-struct-update-with-dtor.rs:28:19
|
LL | let _s2 = S { a: 2, ..s0 };
| ^^^^^^^^^^^^^^^^
| |
| cannot move out of here
| move occurs because `s0.c` has type `K`, which does not implement the `Copy` trait
|
help: clone the value from the field instead of using the spread operator syntax
|
LL | let _s2 = S { a: 2, c: s0.c.clone(), ..s0 };
| +++++++++++++++++
```
```
error[E0509]: cannot move out of type `S<()>`, which implements the `Drop` trait
--> $DIR/borrowck-struct-update-with-dtor.rs:20:19
|
LL | let _s2 = S { a: 2, ..s0 };
| ^^^^^^^^^^^^^^^^
| |
| cannot move out of here
| move occurs because `s0.b` has type `B`, which does not implement the `Copy` trait
|
note: `B` doesn't implement `Copy` or `Clone`
--> $DIR/borrowck-struct-update-with-dtor.rs:4:1
|
LL | struct B;
| ^^^^^^^^
help: if `B` implemented `Clone`, you could clone the value from the field instead of using the spread operator syntax
|
LL | let _s2 = S { a: 2, b: s0.b.clone(), ..s0 };
| +++++++++++++++++
```
2024-03-16 18:19:17 +00:00
|
|
|
|
|
|
|
|
LL | let _s2 = V { a: 2, b: s0.b.clone(), ..s0 };
|
|
|
|
| +++++++++++++++++
|
|
|
|
|
|
|
|
error[E0509]: cannot move out of type `V<K>`, which implements the `Drop` trait
|
|
|
|
--> $DIR/borrowck-struct-update-with-dtor.rs:52:19
|
|
|
|
|
|
|
|
|
LL | let _s2 = V { a: 2, ..s0 };
|
|
|
|
| ^^^^^^^^^^^^^^^^
|
|
|
|
| |
|
|
|
|
| cannot move out of here
|
|
|
|
| move occurs because `s0.c` has type `K`, which does not implement the `Copy` trait
|
|
|
|
|
|
2024-04-12 20:57:07 +00:00
|
|
|
help: clone the value from the field instead of using the functional record update syntax
|
Account for move error in the spread operator on struct literals
We attempt to suggest an appropriate clone for move errors on expressions
like `S { ..s }` where a field isn't `Copy`. If we can't suggest, we still don't
emit the incorrect suggestion of `S { ..s }.clone()`.
```
error[E0509]: cannot move out of type `S<K>`, which implements the `Drop` trait
--> $DIR/borrowck-struct-update-with-dtor.rs:28:19
|
LL | let _s2 = S { a: 2, ..s0 };
| ^^^^^^^^^^^^^^^^
| |
| cannot move out of here
| move occurs because `s0.c` has type `K`, which does not implement the `Copy` trait
|
help: clone the value from the field instead of using the spread operator syntax
|
LL | let _s2 = S { a: 2, c: s0.c.clone(), ..s0 };
| +++++++++++++++++
```
```
error[E0509]: cannot move out of type `S<()>`, which implements the `Drop` trait
--> $DIR/borrowck-struct-update-with-dtor.rs:20:19
|
LL | let _s2 = S { a: 2, ..s0 };
| ^^^^^^^^^^^^^^^^
| |
| cannot move out of here
| move occurs because `s0.b` has type `B`, which does not implement the `Copy` trait
|
note: `B` doesn't implement `Copy` or `Clone`
--> $DIR/borrowck-struct-update-with-dtor.rs:4:1
|
LL | struct B;
| ^^^^^^^^
help: if `B` implemented `Clone`, you could clone the value from the field instead of using the spread operator syntax
|
LL | let _s2 = S { a: 2, b: s0.b.clone(), ..s0 };
| +++++++++++++++++
```
2024-03-16 18:19:17 +00:00
|
|
|
|
|
|
|
|
LL | let _s2 = V { a: 2, c: s0.c.clone(), ..s0 };
|
|
|
|
| +++++++++++++++++
|
|
|
|
|
|
|
|
error[E0509]: cannot move out of type `V<Clonable>`, which implements the `Drop` trait
|
|
|
|
--> $DIR/borrowck-struct-update-with-dtor.rs:58:19
|
|
|
|
|
|
|
|
|
LL | let _s2 = V { a: 2, ..s0 };
|
|
|
|
| ^^^^^^^^^^^^^^^^
|
|
|
|
| |
|
|
|
|
| cannot move out of here
|
|
|
|
| move occurs because `s0.b` has type `Box<isize>`, which does not implement the `Copy` trait
|
|
|
|
|
|
2024-04-12 20:57:07 +00:00
|
|
|
help: clone the value from the field instead of using the functional record update syntax
|
Account for move error in the spread operator on struct literals
We attempt to suggest an appropriate clone for move errors on expressions
like `S { ..s }` where a field isn't `Copy`. If we can't suggest, we still don't
emit the incorrect suggestion of `S { ..s }.clone()`.
```
error[E0509]: cannot move out of type `S<K>`, which implements the `Drop` trait
--> $DIR/borrowck-struct-update-with-dtor.rs:28:19
|
LL | let _s2 = S { a: 2, ..s0 };
| ^^^^^^^^^^^^^^^^
| |
| cannot move out of here
| move occurs because `s0.c` has type `K`, which does not implement the `Copy` trait
|
help: clone the value from the field instead of using the spread operator syntax
|
LL | let _s2 = S { a: 2, c: s0.c.clone(), ..s0 };
| +++++++++++++++++
```
```
error[E0509]: cannot move out of type `S<()>`, which implements the `Drop` trait
--> $DIR/borrowck-struct-update-with-dtor.rs:20:19
|
LL | let _s2 = S { a: 2, ..s0 };
| ^^^^^^^^^^^^^^^^
| |
| cannot move out of here
| move occurs because `s0.b` has type `B`, which does not implement the `Copy` trait
|
note: `B` doesn't implement `Copy` or `Clone`
--> $DIR/borrowck-struct-update-with-dtor.rs:4:1
|
LL | struct B;
| ^^^^^^^^
help: if `B` implemented `Clone`, you could clone the value from the field instead of using the spread operator syntax
|
LL | let _s2 = S { a: 2, b: s0.b.clone(), ..s0 };
| +++++++++++++++++
```
2024-03-16 18:19:17 +00:00
|
|
|
|
|
|
|
|
LL | let _s2 = V { a: 2, b: s0.b.clone(), ..s0 };
|
|
|
|
| +++++++++++++++++
|
|
|
|
|
|
|
|
error[E0509]: cannot move out of type `V<Clonable>`, which implements the `Drop` trait
|
|
|
|
--> $DIR/borrowck-struct-update-with-dtor.rs:58:19
|
|
|
|
|
|
|
|
|
LL | let _s2 = V { a: 2, ..s0 };
|
|
|
|
| ^^^^^^^^^^^^^^^^
|
|
|
|
| |
|
|
|
|
| cannot move out of here
|
|
|
|
| move occurs because `s0.c` has type `Clonable`, which does not implement the `Copy` trait
|
|
|
|
|
|
2024-04-12 20:57:07 +00:00
|
|
|
help: clone the value from the field instead of using the functional record update syntax
|
Account for move error in the spread operator on struct literals
We attempt to suggest an appropriate clone for move errors on expressions
like `S { ..s }` where a field isn't `Copy`. If we can't suggest, we still don't
emit the incorrect suggestion of `S { ..s }.clone()`.
```
error[E0509]: cannot move out of type `S<K>`, which implements the `Drop` trait
--> $DIR/borrowck-struct-update-with-dtor.rs:28:19
|
LL | let _s2 = S { a: 2, ..s0 };
| ^^^^^^^^^^^^^^^^
| |
| cannot move out of here
| move occurs because `s0.c` has type `K`, which does not implement the `Copy` trait
|
help: clone the value from the field instead of using the spread operator syntax
|
LL | let _s2 = S { a: 2, c: s0.c.clone(), ..s0 };
| +++++++++++++++++
```
```
error[E0509]: cannot move out of type `S<()>`, which implements the `Drop` trait
--> $DIR/borrowck-struct-update-with-dtor.rs:20:19
|
LL | let _s2 = S { a: 2, ..s0 };
| ^^^^^^^^^^^^^^^^
| |
| cannot move out of here
| move occurs because `s0.b` has type `B`, which does not implement the `Copy` trait
|
note: `B` doesn't implement `Copy` or `Clone`
--> $DIR/borrowck-struct-update-with-dtor.rs:4:1
|
LL | struct B;
| ^^^^^^^^
help: if `B` implemented `Clone`, you could clone the value from the field instead of using the spread operator syntax
|
LL | let _s2 = S { a: 2, b: s0.b.clone(), ..s0 };
| +++++++++++++++++
```
2024-03-16 18:19:17 +00:00
|
|
|
|
|
|
|
|
LL | let _s2 = V { a: 2, c: s0.c.clone(), ..s0 };
|
|
|
|
| +++++++++++++++++
|
2018-08-08 14:28:26 +02:00
|
|
|
|
Account for move error in the spread operator on struct literals
We attempt to suggest an appropriate clone for move errors on expressions
like `S { ..s }` where a field isn't `Copy`. If we can't suggest, we still don't
emit the incorrect suggestion of `S { ..s }.clone()`.
```
error[E0509]: cannot move out of type `S<K>`, which implements the `Drop` trait
--> $DIR/borrowck-struct-update-with-dtor.rs:28:19
|
LL | let _s2 = S { a: 2, ..s0 };
| ^^^^^^^^^^^^^^^^
| |
| cannot move out of here
| move occurs because `s0.c` has type `K`, which does not implement the `Copy` trait
|
help: clone the value from the field instead of using the spread operator syntax
|
LL | let _s2 = S { a: 2, c: s0.c.clone(), ..s0 };
| +++++++++++++++++
```
```
error[E0509]: cannot move out of type `S<()>`, which implements the `Drop` trait
--> $DIR/borrowck-struct-update-with-dtor.rs:20:19
|
LL | let _s2 = S { a: 2, ..s0 };
| ^^^^^^^^^^^^^^^^
| |
| cannot move out of here
| move occurs because `s0.b` has type `B`, which does not implement the `Copy` trait
|
note: `B` doesn't implement `Copy` or `Clone`
--> $DIR/borrowck-struct-update-with-dtor.rs:4:1
|
LL | struct B;
| ^^^^^^^^
help: if `B` implemented `Clone`, you could clone the value from the field instead of using the spread operator syntax
|
LL | let _s2 = S { a: 2, b: s0.b.clone(), ..s0 };
| +++++++++++++++++
```
2024-03-16 18:19:17 +00:00
|
|
|
error: aborting due to 12 previous errors
|
2018-08-08 14:28:26 +02:00
|
|
|
|
|
|
|
For more information about this error, try `rustc --explain E0509`.
|