]> git.lizzy.rs Git - rust.git/blob - tests/target/impls.rs
Merge pull request #3522 from topecongiro/issue-3521
[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> where T: Baz {}
52
53 impl<T> Foo for Bar<T>
54 where
55     T: Baz,
56 {
57     // Comment
58 }
59
60 impl Foo {
61     fn foo() {}
62 }
63
64 impl Boo {
65     // BOO
66     fn boo() {}
67     // FOO
68 }
69
70 mod a {
71     impl Foo {
72         // Hello!
73         fn foo() {}
74     }
75 }
76
77 mod b {
78     mod a {
79         impl Foo {
80             fn foo() {}
81         }
82     }
83 }
84
85 impl Foo {
86     add_fun!();
87 }
88
89 impl Blah {
90     fn boop() {}
91     add_fun!();
92 }
93
94 impl X {
95     fn do_parse(mut self: X) {}
96 }
97
98 impl Y5000 {
99     fn bar(self: X<'a, 'b>, y: Y) {}
100
101     fn bad(&self, (x, y): CoorT) {}
102
103     fn turbo_bad(self: X<'a, 'b>, (x, y): CoorT) {}
104 }
105
106 pub impl<T> Foo for Bar<T>
107 where
108     T: Foo,
109 {
110     fn foo() {
111         "hi"
112     }
113 }
114
115 pub impl<T, Z> Foo for Bar<T, Z>
116 where
117     T: Foo,
118     Z: Baz,
119 {
120 }
121
122 mod m {
123     impl<T> PartialEq for S<T>
124     where
125         T: PartialEq,
126     {
127         fn eq(&self, other: &Self) {
128             true
129         }
130     }
131
132     impl<T> PartialEq for S<T> where T: PartialEq {}
133 }
134
135 impl<BorrowType, K, V, NodeType, HandleType>
136     Handle<NodeRef<BorrowType, K, V, NodeType>, HandleType>
137 {
138 }
139
140 impl<BorrowType, K, V, NodeType, HandleType> PartialEq
141     for Handle<NodeRef<BorrowType, K, V, NodeType>, HandleType>
142 {
143 }
144
145 mod x {
146     impl<A, B, C, D> Foo
147     where
148         A: 'static,
149         B: 'static,
150         C: 'static,
151         D: 'static,
152     {
153     }
154 }
155
156 impl<ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNodeFoo>
157     Issue1249<ConcreteThreadSafeLayoutNode>
158 {
159     // Creates a new flow constructor.
160     fn foo() {}
161 }
162
163 // #1600
164 impl<#[may_dangle] K, #[may_dangle] V> Drop for RawTable<K, V> {
165     fn drop() {}
166 }
167
168 // #1168
169 pub trait Number:
170     Copy
171     + Eq
172     + Not<Output = Self>
173     + Shl<u8, Output = Self>
174     + Shr<u8, Output = Self>
175     + BitAnd<Self, Output = Self>
176     + BitOr<Self, Output = Self>
177     + BitAndAssign
178     + BitOrAssign
179 {
180     // test
181     fn zero() -> Self;
182 }
183
184 // #1642
185 pub trait SomeTrait:
186     Clone
187     + Eq
188     + PartialEq
189     + Ord
190     + PartialOrd
191     + Default
192     + Hash
193     + Debug
194     + Display
195     + Write
196     + Read
197     + FromStr
198 {
199     // comment
200 }
201
202 // #1995
203 impl Foo {
204     fn f(
205         S {
206             aaaaaaaaaa: aaaaaaaaaa,
207             bbbbbbbbbb: bbbbbbbbbb,
208             cccccccccc: cccccccccc,
209         }: S,
210     ) -> u32 {
211         1
212     }
213 }
214
215 // #2491
216 impl<'a, 'b, 'c> SomeThing<Something>
217     for (
218         &'a mut SomethingLong,
219         &'b mut SomethingLong,
220         &'c mut SomethingLong,
221     )
222 {
223     fn foo() {}
224 }
225
226 // #2746
227 impl<'seq1, 'seq2, 'body, 'scope, Channel>
228     Adc12<
229         Dual,
230         MasterRunningDma<'seq1, 'body, 'scope, Channel>,
231         SlaveRunningDma<'seq2, 'body, 'scope>,
232     >
233 where
234     Channel: DmaChannel,
235 {
236 }