]> git.lizzy.rs Git - rust.git/blob - tests/target/impls.rs
Update tests for traits with long bounds
[rust.git] / tests / target / impls.rs
1 // rustfmt-normalize_comments: true
2 impl Foo for Bar {
3     fn foo() {
4         "hi"
5     }
6 }
7
8 pub impl Foo for Bar {
9     // Associated Constants
10     const Baz: i32 = 16;
11     // Associated Types
12     type FooBar = usize;
13     // Comment 1
14     fn foo() {
15         "hi"
16     }
17     // Comment 2
18     fn foo() {
19         "hi"
20     }
21     // Comment 3
22 }
23
24 pub unsafe impl<'a, 'b, X, Y: Foo<Bar>> !Foo<'a, X> for Bar<'b, Y>
25 where
26     X: Foo<'a, Z>,
27 {
28     fn foo() {
29         "hi"
30     }
31 }
32
33 impl<'a, 'b, X, Y: Foo<Bar>> Foo<'a, X> for Bar<'b, Y>
34 where
35     X: Fooooooooooooooooooooooooooooo<'a, Z>,
36 {
37     fn foo() {
38         "hi"
39     }
40 }
41
42 impl<'a, 'b, X, Y: Foo<Bar>> Foo<'a, X> for Bar<'b, Y>
43 where
44     X: Foooooooooooooooooooooooooooo<'a, Z>,
45 {
46     fn foo() {
47         "hi"
48     }
49 }
50
51 impl<T> Foo for Bar<T>
52 where
53     T: Baz,
54 {
55 }
56
57 impl<T> Foo for Bar<T>
58 where
59     T: Baz,
60 {
61     // Comment
62 }
63
64 impl Foo {
65     fn foo() {}
66 }
67
68 impl Boo {
69     // BOO
70     fn boo() {}
71     // FOO
72 }
73
74 mod a {
75     impl Foo {
76         // Hello!
77         fn foo() {}
78     }
79 }
80
81 mod b {
82     mod a {
83         impl Foo {
84             fn foo() {}
85         }
86     }
87 }
88
89 impl Foo {
90     add_fun!();
91 }
92
93 impl Blah {
94     fn boop() {}
95     add_fun!();
96 }
97
98 impl X {
99     fn do_parse(mut self: X) {}
100 }
101
102 impl Y5000 {
103     fn bar(self: X<'a, 'b>, y: Y) {}
104
105     fn bad(&self, (x, y): CoorT) {}
106
107     fn turbo_bad(self: X<'a, 'b>, (x, y): CoorT) {}
108 }
109
110 pub impl<T> Foo for Bar<T>
111 where
112     T: Foo,
113 {
114     fn foo() {
115         "hi"
116     }
117 }
118
119 pub impl<T, Z> Foo for Bar<T, Z>
120 where
121     T: Foo,
122     Z: Baz,
123 {
124 }
125
126 mod m {
127     impl<T> PartialEq for S<T>
128     where
129         T: PartialEq,
130     {
131         fn eq(&self, other: &Self) {
132             true
133         }
134     }
135
136     impl<T> PartialEq for S<T>
137     where
138         T: PartialEq,
139     {
140     }
141 }
142
143 impl<BorrowType, K, V, NodeType, HandleType>
144     Handle<NodeRef<BorrowType, K, V, NodeType>, HandleType>
145 {
146 }
147
148 impl<BorrowType, K, V, NodeType, HandleType> PartialEq
149     for Handle<NodeRef<BorrowType, K, V, NodeType>, HandleType>
150 {
151 }
152
153 mod x {
154     impl<A, B, C, D> Foo
155     where
156         A: 'static,
157         B: 'static,
158         C: 'static,
159         D: 'static,
160     {
161     }
162 }
163
164 impl<ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNodeFoo>
165     Issue1249<ConcreteThreadSafeLayoutNode>
166 {
167     // Creates a new flow constructor.
168     fn foo() {}
169 }
170
171 // #1600
172 impl<#[may_dangle] K, #[may_dangle] V> Drop for RawTable<K, V> {
173     fn drop() {}
174 }
175
176 // #1168
177 pub trait Number:
178     Copy
179     + Eq
180     + Not<Output = Self>
181     + Shl<u8, Output = Self>
182     + Shr<u8, Output = Self>
183     + BitAnd<Self, Output = Self>
184     + BitOr<Self, Output = Self>
185     + BitAndAssign
186     + BitOrAssign
187 {
188     // test
189     fn zero() -> Self;
190 }
191
192 // #1642
193 pub trait SomeTrait:
194     Clone
195     + Eq
196     + PartialEq
197     + Ord
198     + PartialOrd
199     + Default
200     + Hash
201     + Debug
202     + Display
203     + Write
204     + Read
205     + FromStr
206 {
207     // comment
208 }
209
210 // #1995
211 impl Foo {
212     fn f(
213         S {
214             aaaaaaaaaa: aaaaaaaaaa,
215             bbbbbbbbbb: bbbbbbbbbb,
216             cccccccccc: cccccccccc,
217         }: S,
218     ) -> u32 {
219         1
220     }
221 }
222
223 // #2491
224 impl<'a, 'b, 'c> SomeThing<Something>
225     for (
226         &'a mut SomethingLong,
227         &'b mut SomethingLong,
228         &'c mut SomethingLong,
229     )
230 {
231     fn foo() {}
232 }