Commit graph

2 commits

Author SHA1 Message Date
许杰友 Jieyou Xu (Joe) ec2cc761bc
[AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
Esteban Küber a754fcaa43 On "this .clone() is on the reference", provide more info
When encountering a case where `let x: T = (val: &T).clone();` and
`T: !Clone`, already mention that the reference is being cloned. We now
also suggest `#[derive(Clone)]` not only on `T` but also on type
parameters to satisfy blanket implementations.

```
error[E0308]: mismatched types
  --> $DIR/assignment-of-clone-call-on-ref-due-to-missing-bound.rs:17:39
   |
LL |             let mut x: HashSet<Day> = v.clone();
   |                        ------------   ^^^^^^^^^ expected `HashSet<Day>`, found `&HashSet<Day>`
   |                        |
   |                        expected due to this
   |
   = note: expected struct `HashSet<Day>`
           found reference `&HashSet<Day>`
note: `HashSet<Day>` does not implement `Clone`, so `&HashSet<Day>` was cloned instead
  --> $DIR/assignment-of-clone-call-on-ref-due-to-missing-bound.rs:17:39
   |
LL |             let mut x: HashSet<Day> = v.clone();
   |                                       ^
   = help: `Clone` is not implemented because the trait bound `Day: Clone` is not satisfied
help: consider annotating `Day` with `#[derive(Clone)]`
   |
LL + #[derive(Clone)]
LL | enum Day {
   |
```

Case taken from # #41825.
2023-12-04 21:54:33 +00:00