]>
Commit | Line | Data |
---|---|---|
5e7ed085 FG |
1 | // run-rustfix |
2 | #![allow(dead_code)] | |
3 | ||
4 | fn duplicate_t<T>(t: T) -> (T, T) { | |
5 | //~^ HELP consider restricting type parameter `T` | |
6 | (t, t) //~ use of moved value: `t` | |
7 | } | |
8 | ||
9 | fn duplicate_opt<T>(t: Option<T>) -> (Option<T>, Option<T>) { | |
10 | //~^ HELP consider restricting type parameter `T` | |
11 | (t, t) //~ use of moved value: `t` | |
12 | } | |
13 | ||
14 | fn duplicate_tup1<T>(t: (T,)) -> ((T,), (T,)) { | |
15 | //~^ HELP consider restricting type parameter `T` | |
16 | (t, t) //~ use of moved value: `t` | |
17 | } | |
18 | ||
19 | fn duplicate_tup2<A, B>(t: (A, B)) -> ((A, B), (A, B)) { | |
20 | //~^ HELP consider restricting type parameters | |
21 | (t, t) //~ use of moved value: `t` | |
22 | } | |
23 | ||
24 | fn duplicate_custom<T>(t: S<T>) -> (S<T>, S<T>) { | |
25 | //~^ HELP consider restricting type parameter `T` | |
26 | (t, t) //~ use of moved value: `t` | |
27 | } | |
28 | ||
29 | struct S<T>(T); | |
30 | trait Trait {} | |
31 | impl<T: Trait + Clone> Clone for S<T> { | |
32 | fn clone(&self) -> Self { | |
33 | Self(self.0.clone()) | |
34 | } | |
35 | } | |
36 | impl<T: Trait + Copy> Copy for S<T> {} | |
37 | ||
38 | trait A {} | |
39 | trait B {} | |
40 | ||
41 | // Test where bounds are added with different bound placements | |
42 | fn duplicate_custom_1<T>(t: S<T>) -> (S<T>, S<T>) where { | |
43 | //~^ HELP consider restricting type parameter `T` | |
44 | (t, t) //~ use of moved value: `t` | |
45 | } | |
46 | ||
47 | fn duplicate_custom_2<T>(t: S<T>) -> (S<T>, S<T>) | |
48 | where | |
49 | T: A, | |
50 | //~^ HELP consider further restricting this bound | |
51 | { | |
52 | (t, t) //~ use of moved value: `t` | |
53 | } | |
54 | ||
55 | fn duplicate_custom_3<T>(t: S<T>) -> (S<T>, S<T>) | |
56 | where | |
57 | T: A, | |
04454e1e | 58 | //~^ HELP consider further restricting this bound |
5e7ed085 | 59 | T: B, |
5e7ed085 FG |
60 | { |
61 | (t, t) //~ use of moved value: `t` | |
62 | } | |
63 | ||
64 | fn duplicate_custom_4<T: A>(t: S<T>) -> (S<T>, S<T>) | |
04454e1e | 65 | //~^ HELP consider further restricting this bound |
5e7ed085 FG |
66 | where |
67 | T: B, | |
5e7ed085 FG |
68 | { |
69 | (t, t) //~ use of moved value: `t` | |
70 | } | |
71 | ||
04454e1e FG |
72 | #[rustfmt::skip] |
73 | fn existing_colon<T:>(t: T) { | |
74 | //~^ HELP consider restricting type parameter `T` | |
75 | [t, t]; //~ use of moved value: `t` | |
76 | } | |
77 | ||
78 | fn existing_colon_in_where<T>(t: T) | |
79 | where | |
80 | T:, | |
81 | //~^ HELP consider further restricting type parameter `T` | |
82 | { | |
83 | [t, t]; //~ use of moved value: `t` | |
84 | } | |
85 | ||
5e7ed085 | 86 | fn main() {} |