rust/tests
Esteban Küber d578ac9e47 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-04-11 16:41:42 +00:00
..
assembly
auxiliary
codegen Auto merge of #123185 - scottmcm:more-typed-copy, r=compiler-errors 2024-04-10 16:32:41 +00:00
codegen-units
coverage
coverage-run-rustdoc
debuginfo
incremental
mir-opt Auto merge of #122387 - DianQK:re-enable-early-otherwise-branch, r=cjgillot 2024-04-09 01:02:29 +00:00
pretty
run-make Rollup merge of #123612 - kxxt:riscv-target-abi, r=jieyouxu,nikic,DianQK 2024-04-10 04:27:40 +02:00
run-make-fulldeps
run-pass-valgrind
rustdoc
rustdoc-gui rustdoc: update test cases 2024-04-09 20:22:13 -07:00
rustdoc-js
rustdoc-js-std
rustdoc-json
rustdoc-ui tests: bless ui and rustdoc-ui tests for ICE messages 2024-04-09 13:58:52 +00:00
ui Account for move error in the spread operator on struct literals 2024-04-11 16:41:42 +00:00
ui-fulldeps Rollup merge of #123659 - celinval:smir-fix-intrinsic, r=oli-obk 2024-04-10 16:15:23 +02:00
COMPILER_TESTS.md