rust/tests/ui/union
Esteban Küber d68f2a6b71 Mention when type parameter could be `Clone`
```
error[E0382]: use of moved value: `t`
  --> $DIR/use_of_moved_value_copy_suggestions.rs:7:9
   |
LL | fn duplicate_t<T>(t: T) -> (T, T) {
   |                   - move occurs because `t` has type `T`, which does not implement the `Copy` trait
...
LL |     (t, t)
   |      -  ^ value used here after move
   |      |
   |      value moved here
   |
help: if `T` implemented `Clone`, you could clone the value
  --> $DIR/use_of_moved_value_copy_suggestions.rs:4:16
   |
LL | fn duplicate_t<T>(t: T) -> (T, T) {
   |                ^ consider constraining this type parameter with `Clone`
...
LL |     (t, t)
   |      - you could clone this value
help: consider restricting type parameter `T`
   |
LL | fn duplicate_t<T: Copy>(t: T) -> (T, T) {
   |                 ++++++
```

The `help` is new. On ADTs, we also extend the output with span labels:

```
error[E0507]: cannot move out of static item `FOO`
  --> $DIR/issue-17718-static-move.rs:6:14
   |
LL |     let _a = FOO;
   |              ^^^ move occurs because `FOO` has type `Foo`, which does not implement the `Copy` trait
   |
note: if `Foo` implemented `Clone`, you could clone the value
  --> $DIR/issue-17718-static-move.rs:1:1
   |
LL | struct Foo;
   | ^^^^^^^^^^ consider implementing `Clone` for this type
...
LL |     let _a = FOO;
   |              --- you could clone this value
help: consider borrowing here
   |
LL |     let _a = &FOO;
   |              +
```
2024-04-24 22:21:15 +00:00
..
auxiliary Move /src/test to /tests 2023-01-11 09:32:08 +00:00
unnamed-fields hir_analysis: enums return `None` in `find_field` 2024-03-04 11:38:16 +00:00
field_checks.rs Tweak E0740 2023-03-08 01:58:15 +00:00
field_checks.stderr Tweak E0740 2023-03-08 01:58:15 +00:00
issue-41073.rs Tweak E0740 2023-03-08 01:58:15 +00:00
issue-41073.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-81199.rs raw pointer metadata API: data address -> data pointer 2024-01-29 07:56:38 +01:00
issue-81199.stderr Work around the fact that `check_mod_type_wf` may spuriously return `ErrorGuaranteed`, even if that error is only emitted by `check_modwitem_types` 2023-10-25 12:04:54 +00:00
issue-99375.rs [AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00
projection-as-union-type-error-2.rs Add failing test for invalid projection as union field type 2023-01-17 14:00:55 +01:00
projection-as-union-type-error-2.stderr Provide more context on derived obligation error primary label 2024-01-30 21:28:18 +00:00
projection-as-union-type-error.rs Add failing test for invalid projection as union field type 2023-01-17 14:00:55 +01:00
projection-as-union-type-error.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
projection-as-union-type.rs [AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00
union-align.rs [AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00
union-backcomp.rs [AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00
union-basic.rs [AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00
union-borrow-move-parent-sibling.rs Remove revisions for THIR unsafeck 2024-01-05 09:30:27 +00:00
union-borrow-move-parent-sibling.stderr Mention when type parameter could be `Clone` 2024-04-24 22:21:15 +00:00
union-const-codegen.rs [AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00
union-const-eval-field.rs [AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00
union-const-eval.rs [AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00
union-const-pat.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
union-const-pat.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
union-copy.rs may not => cannot 2023-03-08 00:00:18 +00:00
union-copy.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
union-deref.rs Remove revisions for THIR unsafeck 2024-01-05 09:30:27 +00:00
union-deref.stderr Remove revisions for THIR unsafeck 2024-01-05 09:30:27 +00:00
union-derive-clone.rs Remove revisions for THIR unsafeck 2024-01-05 09:30:27 +00:00
union-derive-clone.stderr Use single label for method not found due to unmet bound 2024-01-26 20:47:19 +00:00
union-derive-eq.rs Remove revisions for THIR unsafeck 2024-01-05 09:30:27 +00:00
union-derive-eq.stderr Remove revisions for THIR unsafeck 2024-01-05 09:30:27 +00:00
union-derive-rpass.rs [AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00
union-derive.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
union-derive.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
union-drop-assign.rs [AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00
union-drop.rs [AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00
union-empty.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
union-empty.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
union-fields-1.rs Remove revisions for THIR unsafeck 2024-01-05 09:30:27 +00:00
union-fields-1.stderr Remove revisions for THIR unsafeck 2024-01-05 09:30:27 +00:00
union-fields-2.rs Remove revisions for THIR unsafeck 2024-01-05 09:30:27 +00:00
union-fields-2.stderr Remove revisions for THIR unsafeck 2024-01-05 09:30:27 +00:00
union-generic-rpass.rs [AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00
union-generic.rs Remove revisions for THIR unsafeck 2024-01-05 09:30:27 +00:00
union-generic.stderr Remove revisions for THIR unsafeck 2024-01-05 09:30:27 +00:00
union-inherent-method.rs [AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00
union-lint-dead-code.rs Remove revisions for THIR unsafeck 2024-01-05 09:30:27 +00:00
union-lint-dead-code.stderr Remove revisions for THIR unsafeck 2024-01-05 09:30:27 +00:00
union-macro.rs Allow unused fields in some tests 2024-03-12 10:59:41 +01:00
union-manuallydrop-rpass.rs [AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00
union-move.rs Remove revisions for THIR unsafeck 2024-01-05 09:30:27 +00:00
union-move.stderr Mention when type parameter could be `Clone` 2024-04-24 22:21:15 +00:00
union-nodrop.rs [AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00
union-nonrepresentable.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
union-nonrepresentable.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
union-nonzero.rs [AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00
union-overwrite.rs [AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00
union-packed.rs [AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00
union-pat-refutability.rs [AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00
union-repr-c.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
union-repr-c.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
union-sized-field.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
union-sized-field.stderr change `std::marker::Sized` to just `Sized` 2023-06-15 12:01:38 +02:00
union-suggest-field.rs Remove revisions for THIR unsafeck 2024-01-05 09:30:27 +00:00
union-suggest-field.stderr Remove revisions for THIR unsafeck 2024-01-05 09:30:27 +00:00
union-trait-impl.rs [AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00
union-transmute.rs [AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00
union-unsafe.rs Remove revisions for THIR unsafeck 2024-01-05 09:30:27 +00:00
union-unsafe.stderr Stabilize THIR unsafeck 2024-01-05 10:00:59 +00:00
union-unsized.rs Remove revisions for THIR unsafeck 2024-01-05 09:30:27 +00:00
union-unsized.stderr Stabilize THIR unsafeck 2024-01-05 10:00:59 +00:00
union-with-drop-fields.rs Remove revisions for THIR unsafeck 2024-01-05 09:30:27 +00:00
union-with-drop-fields.stderr Remove revisions for THIR unsafeck 2024-01-05 09:30:27 +00:00
unresolved-field-isnt-copy.rs Don't report E0740 for type error 2023-03-08 01:55:32 +00:00
unresolved-field-isnt-copy.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00