summaryrefslogtreecommitdiffstats
path: root/tests/ui/suggestions/clone-on-unconstrained-borrowed-type-param.stderr
blob: 26ab515d9b4b6fd0c84c8b5c58d818ecf88fdf98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
error[E0308]: mismatched types
  --> $DIR/clone-on-unconstrained-borrowed-type-param.rs:3:5
   |
LL | fn wat<T>(t: &T) -> T {
   |        -            - expected `T` because of return type
   |        |
   |        this type parameter
LL |     t.clone()
   |     ^^^^^^^^^ expected type parameter `T`, found `&T`
   |
   = note: expected type parameter `T`
                   found reference `&T`
note: `T` does not implement `Clone`, so `&T` was cloned instead
  --> $DIR/clone-on-unconstrained-borrowed-type-param.rs:3:5
   |
LL |     t.clone()
   |     ^
help: consider restricting type parameter `T`
   |
LL | fn wat<T: Clone>(t: &T) -> T {
   |         +++++++

error[E0308]: mismatched types
  --> $DIR/clone-on-unconstrained-borrowed-type-param.rs:9:5
   |
LL | fn wut(t: &Foo) -> Foo {
   |                    --- expected `Foo` because of return type
LL |     t.clone()
   |     ^^^^^^^^^ expected struct `Foo`, found `&Foo`
   |
note: `Foo` does not implement `Clone`, so `&Foo` was cloned instead
  --> $DIR/clone-on-unconstrained-borrowed-type-param.rs:9:5
   |
LL |     t.clone()
   |     ^
help: consider annotating `Foo` with `#[derive(Clone)]`
   |
LL | #[derive(Clone)]
   |

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0308`.