rust/tests/ui/derives
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 Avoid expanding to unstable internal method 2024-04-02 22:21:16 +00:00
clone-debug-dead-code-in-the-same-struct.rs
clone-debug-dead-code-in-the-same-struct.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
clone-debug-dead-code.rs
clone-debug-dead-code.stderr
derive-assoc-type-not-impl.rs
derive-assoc-type-not-impl.stderr Account for non-overlapping unmet trait bounds in suggestion 2024-01-30 19:26:13 +00:00
derive-deadlock.rs
derive-deadlock.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
derive-Debug-use-ufcs-struct.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
derive-Debug-use-ufcs-tuple.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
derive-hygiene.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
derive-macro-const-default.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
derive-marker-tricky.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
derive-multiple-with-packed.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
derive-on-trait-item-or-impl-item.rs
derive-on-trait-item-or-impl-item.stderr
derive-partial-ord.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
derive-renamed.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
derives-span-Clone-enum-struct-variant.rs
derives-span-Clone-enum-struct-variant.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
derives-span-Clone-enum.rs
derives-span-Clone-enum.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
derives-span-Clone-struct.rs
derives-span-Clone-struct.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
derives-span-Clone-tuple-struct.rs
derives-span-Clone-tuple-struct.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
derives-span-Debug-enum-struct-variant.rs
derives-span-Debug-enum-struct-variant.stderr Provide more context on derived obligation error primary label 2024-01-30 21:28:18 +00:00
derives-span-Debug-enum.rs
derives-span-Debug-enum.stderr Provide more context on derived obligation error primary label 2024-01-30 21:28:18 +00:00
derives-span-Debug-struct.rs
derives-span-Debug-struct.stderr Provide more context on derived obligation error primary label 2024-01-30 21:28:18 +00:00
derives-span-Debug-tuple-struct.rs
derives-span-Debug-tuple-struct.stderr Provide more context on derived obligation error primary label 2024-01-30 21:28:18 +00:00
derives-span-Default-struct.rs
derives-span-Default-struct.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
derives-span-Default-tuple-struct.rs
derives-span-Default-tuple-struct.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
derives-span-Eq-enum-struct-variant.rs
derives-span-Eq-enum-struct-variant.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
derives-span-Eq-enum.rs
derives-span-Eq-enum.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
derives-span-Eq-struct.rs
derives-span-Eq-struct.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
derives-span-Eq-tuple-struct.rs
derives-span-Eq-tuple-struct.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
derives-span-Hash-enum-struct-variant.rs
derives-span-Hash-enum-struct-variant.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
derives-span-Hash-enum.rs
derives-span-Hash-enum.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
derives-span-Hash-struct.rs
derives-span-Hash-struct.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
derives-span-Hash-tuple-struct.rs
derives-span-Hash-tuple-struct.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
derives-span-Ord-enum-struct-variant.rs
derives-span-Ord-enum-struct-variant.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
derives-span-Ord-enum.rs
derives-span-Ord-enum.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
derives-span-Ord-struct.rs
derives-span-Ord-struct.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
derives-span-Ord-tuple-struct.rs
derives-span-Ord-tuple-struct.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
derives-span-PartialEq-enum-struct-variant.rs
derives-span-PartialEq-enum-struct-variant.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
derives-span-PartialEq-enum.rs
derives-span-PartialEq-enum.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
derives-span-PartialEq-struct.rs
derives-span-PartialEq-struct.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
derives-span-PartialEq-tuple-struct.rs
derives-span-PartialEq-tuple-struct.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
derives-span-PartialOrd-enum-struct-variant.rs
derives-span-PartialOrd-enum-struct-variant.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
derives-span-PartialOrd-enum.rs
derives-span-PartialOrd-enum.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
derives-span-PartialOrd-struct.rs
derives-span-PartialOrd-struct.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
derives-span-PartialOrd-tuple-struct.rs
derives-span-PartialOrd-tuple-struct.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
deriving-bounds.rs
deriving-bounds.stderr
deriving-copyclone.rs
deriving-copyclone.stderr
deriving-meta-empty-trait-list.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
deriving-meta-unknown-trait.rs
deriving-meta-unknown-trait.stderr
deriving-no-inner-impl-error-message.rs
deriving-no-inner-impl-error-message.stderr
deriving-non-type.rs
deriving-non-type.stderr
deriving-primitive.rs
deriving-primitive.stderr
deriving-with-repr-packed-2.rs
deriving-with-repr-packed-2.stderr Use single label for method not found due to unmet bound 2024-01-26 20:47:19 +00:00
deriving-with-repr-packed-move-errors.rs Emit explanatory note for move errors in packed struct derives 2023-11-03 07:32:10 +05:30
deriving-with-repr-packed-move-errors.stderr Suggest .clone() in some move errors 2024-04-11 16:41:41 +00:00
deriving-with-repr-packed.rs
deriving-with-repr-packed.stderr Mention when type parameter could be Clone 2024-04-24 22:21:15 +00:00
issue-36617.rs Supress unhelpful diagnostics for unresolved top level attributes 2024-01-29 17:43:07 +08:00
issue-36617.stderr Supress unhelpful diagnostics for unresolved top level attributes 2024-01-29 17:43:07 +08:00
issue-43023.rs
issue-43023.stderr
issue-91492.rs
issue-91492.stderr
issue-91550.rs
issue-91550.stderr Use fulfillment, not evaluate, during method probe 2024-04-21 20:10:12 -04:00
issue-97343.rs Taint more aggressively in astconv 2024-01-11 09:03:26 +00:00
issue-97343.stderr Taint more aggressively in astconv 2024-01-11 09:03:26 +00:00
rustc-decodable-issue-123156.rs Avoid expanding to unstable internal method 2024-04-02 22:21:16 +00:00
rustc-decodable-issue-123156.stderr Avoid expanding to unstable internal method 2024-04-02 22:21:16 +00:00