rust/tests/ui/variance
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
..
leaking-unnameables.rs Don't leak unnameable types in -> _ recover 2024-04-14 11:43:05 -04:00
leaking-unnameables.stderr Don't leak unnameable types in -> _ recover 2024-04-14 11:43:05 -04:00
variance-associated-consts.rs Merge check_mod_impl_wf and check_mod_type_wf 2024-03-07 06:27:09 +00:00
variance-associated-consts.stderr Provide structured suggestion for unconstrained generic constant 2024-03-21 00:03:59 +00:00
variance-associated-types2.rs
variance-associated-types2.stderr
variance-associated-types.rs
variance-associated-types.stderr
variance-btree-invariant-types.rs
variance-btree-invariant-types.stderr
variance-cell-is-invariant.rs
variance-cell-is-invariant.stderr
variance-contravariant-arg-object.rs
variance-contravariant-arg-object.stderr
variance-contravariant-arg-trait-match.rs
variance-contravariant-arg-trait-match.stderr
variance-contravariant-self-trait-match.rs
variance-contravariant-self-trait-match.stderr
variance-covariant-arg-object.rs
variance-covariant-arg-object.stderr
variance-covariant-arg-trait-match.rs
variance-covariant-arg-trait-match.stderr
variance-covariant-self-trait-match.rs
variance-covariant-self-trait-match.stderr
variance-intersection-of-ref-and-opt-ref.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
variance-invariant-arg-object.rs
variance-invariant-arg-object.stderr
variance-invariant-arg-trait-match.rs
variance-invariant-arg-trait-match.stderr
variance-invariant-self-trait-match.rs
variance-invariant-self-trait-match.stderr
variance-issue-20533.rs When possible, suggest cloning the result of a call instead of an argument 2024-04-11 16:41:41 +00:00
variance-issue-20533.stderr Mention when type parameter could be Clone 2024-04-24 22:21:15 +00:00
variance-iterators-in-libcore.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
variance-object-types.rs
variance-object-types.stderr
variance-regions-direct.rs Merge check_mod_impl_wf and check_mod_type_wf 2024-03-07 06:27:09 +00:00
variance-regions-direct.stderr Revert "Auto merge of #122140 - oli-obk:track_errors13, r=davidtwco" 2024-03-11 21:28:16 +00:00
variance-regions-indirect.rs Merge check_mod_impl_wf and check_mod_type_wf 2024-03-07 06:27:09 +00:00
variance-regions-indirect.stderr Revert "Auto merge of #122140 - oli-obk:track_errors13, r=davidtwco" 2024-03-11 21:28:16 +00:00
variance-regions-unused-direct.rs
variance-regions-unused-direct.stderr
variance-regions-unused-indirect.rs
variance-regions-unused-indirect.stderr
variance-trait-bounds.rs Merge check_mod_impl_wf and check_mod_type_wf 2024-03-07 06:27:09 +00:00
variance-trait-bounds.stderr Revert "Auto merge of #122140 - oli-obk:track_errors13, r=davidtwco" 2024-03-11 21:28:16 +00:00
variance-trait-matching.rs
variance-trait-matching.stderr
variance-trait-object-bound.rs
variance-trait-object-bound.stderr
variance-types-bounds.rs
variance-types-bounds.stderr
variance-types.rs
variance-types.stderr
variance-unused-region-param.rs
variance-unused-region-param.stderr
variance-unused-type-param.rs
variance-unused-type-param.stderr
variance-use-contravariant-struct-1.rs
variance-use-contravariant-struct-1.stderr
variance-use-contravariant-struct-2.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
variance-use-covariant-struct-1.rs
variance-use-covariant-struct-1.stderr
variance-use-covariant-struct-2.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
variance-use-invariant-struct-1.rs
variance-use-invariant-struct-1.stderr