]> git.lizzy.rs Git - rust.git/blob - tests/ui/suggestions/clone-on-unconstrained-borrowed-type-param.stderr
Rollup merge of #106670 - albertlarsan68:check-docs-in-pr-ci, r=Mark-Simulacrum
[rust.git] / tests / ui / suggestions / clone-on-unconstrained-borrowed-type-param.stderr
1 error[E0308]: mismatched types
2   --> $DIR/clone-on-unconstrained-borrowed-type-param.rs:3:5
3    |
4 LL | fn wat<T>(t: &T) -> T {
5    |        -            - expected `T` because of return type
6    |        |
7    |        this type parameter
8 LL |     t.clone()
9    |     ^^^^^^^^^ expected type parameter `T`, found `&T`
10    |
11    = note: expected type parameter `T`
12                    found reference `&T`
13 note: `T` does not implement `Clone`, so `&T` was cloned instead
14   --> $DIR/clone-on-unconstrained-borrowed-type-param.rs:3:5
15    |
16 LL |     t.clone()
17    |     ^
18 help: consider restricting type parameter `T`
19    |
20 LL | fn wat<T: Clone>(t: &T) -> T {
21    |         +++++++
22
23 error[E0308]: mismatched types
24   --> $DIR/clone-on-unconstrained-borrowed-type-param.rs:9:5
25    |
26 LL | fn wut(t: &Foo) -> Foo {
27    |                    --- expected `Foo` because of return type
28 LL |     t.clone()
29    |     ^^^^^^^^^ expected struct `Foo`, found `&Foo`
30    |
31 note: `Foo` does not implement `Clone`, so `&Foo` was cloned instead
32   --> $DIR/clone-on-unconstrained-borrowed-type-param.rs:9:5
33    |
34 LL |     t.clone()
35    |     ^
36 help: consider annotating `Foo` with `#[derive(Clone)]`
37    |
38 LL | #[derive(Clone)]
39    |
40
41 error: aborting due to 2 previous errors
42
43 For more information about this error, try `rustc --explain E0308`.