]> git.lizzy.rs Git - rust.git/blob - src/test/ui/suggestions/suggest-move-types.rs
Rollup merge of #65276 - varkor:toolstate-no-ping, r=Mark-Simulacrum
[rust.git] / src / test / ui / suggestions / suggest-move-types.rs
1 // ignore-tidy-linelength
2
3 #![allow(warnings)]
4
5 // This test verifies that the suggestion to move types before associated type bindings
6 // is correct.
7
8 trait One<T> {
9   type A;
10 }
11
12 trait OneWithLifetime<'a, T> {
13   type A;
14 }
15
16 trait Three<T, U, V> {
17   type A;
18   type B;
19   type C;
20 }
21
22 trait ThreeWithLifetime<'a, 'b, 'c, T, U, V> {
23   type A;
24   type B;
25   type C;
26 }
27
28 struct A<T, M: One<A=(), T>> { //~ ERROR associated type bindings must be declared after generic parameters
29     m: M,
30     t: T,
31 }
32
33
34 struct Al<'a, T, M: OneWithLifetime<A=(), T, 'a>> {
35 //~^ ERROR associated type bindings must be declared after generic parameters
36 //~^^ ERROR lifetime arguments must be declared prior to type arguments
37     m: M,
38     t: &'a T,
39 }
40
41 struct B<T, U, V, M: Three<A=(), B=(), C=(), T, U, V>> { //~ ERROR associated type bindings must be declared after generic parameters
42     m: M,
43     t: T,
44     u: U,
45     v: V,
46 }
47
48 struct Bl<'a, 'b, 'c, T, U, V, M: ThreeWithLifetime<A=(), B=(), C=(), T, U, V, 'a, 'b, 'c>> {
49 //~^ ERROR associated type bindings must be declared after generic parameters
50 //~^^ ERROR lifetime arguments must be declared prior to type arguments
51     m: M,
52     t: &'a T,
53     u: &'b U,
54     v: &'c V,
55 }
56
57 struct C<T, U, V, M: Three<T, A=(), B=(), C=(), U, V>> { //~ ERROR associated type bindings must be declared after generic parameters
58     m: M,
59     t: T,
60     u: U,
61     v: V,
62 }
63
64 struct Cl<'a, 'b, 'c, T, U, V, M: ThreeWithLifetime<T, 'a, A=(), B=(), C=(), U, 'b, V, 'c>> {
65 //~^ ERROR associated type bindings must be declared after generic parameters
66 //~^^ ERROR lifetime arguments must be declared prior to type arguments
67     m: M,
68     t: &'a T,
69     u: &'b U,
70     v: &'c V,
71 }
72
73 struct D<T, U, V, M: Three<T, A=(), B=(), U, C=(), V>> { //~ ERROR associated type bindings must be declared after generic parameters
74     m: M,
75     t: T,
76     u: U,
77     v: V,
78 }
79
80 struct Dl<'a, 'b, 'c, T, U, V, M: ThreeWithLifetime<T, 'a, A=(), B=(), U, 'b, C=(), V, 'c>> {
81 //~^ ERROR associated type bindings must be declared after generic parameters
82 //~^^ ERROR lifetime arguments must be declared prior to type arguments
83     m: M,
84     t: &'a T,
85     u: &'b U,
86     v: &'c V,
87 }
88
89 fn main() {}