diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2023-11-21 01:09:11 +0000 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2023-12-04 21:54:33 +0000 |
| commit | a754fcaa43e02472ff9e1971e0e7085f58a6f041 (patch) | |
| tree | 9b1123473b7ac9f96844ef2f35b1618300f98d5a /compiler/rustc_trait_selection/src/errors.rs | |
| parent | 1c69c6ab0890a8a4df947e41102dc667d668718e (diff) | |
| download | rust-a754fcaa43e02472ff9e1971e0e7085f58a6f041.tar.gz rust-a754fcaa43e02472ff9e1971e0e7085f58a6f041.zip | |
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.
Diffstat (limited to 'compiler/rustc_trait_selection/src/errors.rs')
0 files changed, 0 insertions, 0 deletions
