rust/tests/ui/binop
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
..
binary-minus-without-space.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
binary-op-on-double-ref.fixed [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
binary-op-on-double-ref.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
binary-op-on-double-ref.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
binary-op-on-fn-ptr-eq.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
binary-op-suggest-deref.rs Fix ICE when suggesting dereferencing binop operands 2024-01-12 17:49:37 -08:00
binary-op-suggest-deref.stderr Add basic trait impls for f16 and f128 2024-03-28 15:02:51 -04:00
binop-bitxor-str.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
binop-bitxor-str.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
binop-consume-args.rs
binop-consume-args.stderr Mention when type parameter could be Clone 2024-04-24 22:21:15 +00:00
binop-fail-3.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
binop-logic-float.rs
binop-logic-float.stderr
binop-logic-int.rs
binop-logic-int.stderr
binop-move-semantics.rs
binop-move-semantics.stderr Mention when type parameter could be Clone 2024-04-24 22:21:15 +00:00
binop-mul-bool.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
binop-mul-bool.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
binop-mul-i32-f32.rs
binop-mul-i32-f32.stderr Use TraitRef::to_string sorting in favor of TraitRef::ord, as the latter compares DefIds which we need to avoid 2024-03-27 14:02:15 +00:00
binop-panic.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
binop-typeck.rs
binop-typeck.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
binops-issue-22743.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
binops.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
borrow-suggestion-109352-2.rs Improve diagnostic for wrong borrow on binary operations 2023-08-01 10:08:17 +02:00
borrow-suggestion-109352-2.stderr Improve diagnostic for wrong borrow on binary operations 2023-08-01 10:08:17 +02:00
borrow-suggestion-109352.fixed [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
borrow-suggestion-109352.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
borrow-suggestion-109352.stderr Improve diagnostic for wrong borrow on binary operations 2023-08-01 10:08:17 +02:00
eq-arr.rs Provide RHS type hint when reporting operator error 2023-04-27 01:34:03 +00:00
eq-arr.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
eq-vec.rs Provide RHS type hint when reporting operator error 2023-04-27 01:34:03 +00:00
eq-vec.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
false-binop-caused-by-missing-semi.fixed [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
false-binop-caused-by-missing-semi.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
false-binop-caused-by-missing-semi.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-3820.rs
issue-3820.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-25916.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-28837.rs Improved wording of error messages of missing remainder implementations 2023-01-30 19:54:33 +00:00
issue-28837.stderr Provide RHS type hint when reporting operator error 2023-04-27 01:34:03 +00:00
issue-62375.rs Move some tests 2024-02-09 15:43:08 -03:00
issue-62375.stderr Move some tests 2024-02-09 15:43:08 -03:00
issue-77910-1.rs Continue to borrowck even if there were previous errors 2024-02-08 08:10:43 +00:00
issue-77910-1.stderr Handle more cases of value suggestions 2024-04-10 20:36:14 +00:00
issue-77910-2.rs Continue to borrowck even if there were previous errors 2024-02-08 08:10:43 +00:00
issue-77910-2.stderr Handle more cases of value suggestions 2024-04-10 20:36:14 +00:00
issue-93927.rs
issue-93927.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
multiply-is-deref-on-rhs.rs Don't delay a bug if we suggest adding a semicolon to the RHS of an assign operator 2024-04-10 15:07:13 -04:00
multiply-is-deref-on-rhs.stderr Don't delay a bug if we suggest adding a semicolon to the RHS of an assign operator 2024-04-10 15:07:13 -04:00
operator-multidispatch.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
operator-overloading.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
placement-syntax.rs
placement-syntax.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
shift-various-bad-types.rs
shift-various-bad-types.stderr Use TraitRef::to_string sorting in favor of TraitRef::ord, as the latter compares DefIds which we need to avoid 2024-03-27 14:02:15 +00:00
structured-compare.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00