]> git.lizzy.rs Git - rust.git/blob - src/tools/rustfmt/tests/target/impls.rs
Merge commit 'e36a20c24f35a4cee82bbdc600289104c9237c22' into ra-sync-and-pms-component
[rust.git] / src / tools / rustfmt / 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 #[inherent]
25 impl Visible for Bar {
26     pub const C: i32;
27     pub type T;
28     pub fn f();
29     pub fn g() {}
30 }
31
32 pub unsafe impl<'a, 'b, X, Y: Foo<Bar>> !Foo<'a, X> for Bar<'b, Y>
33 where
34     X: Foo<'a, Z>,
35 {
36     fn foo() {
37         "hi"
38     }
39 }
40
41 impl<'a, 'b, X, Y: Foo<Bar>> Foo<'a, X> for Bar<'b, Y>
42 where
43     X: Fooooooooooooooooooooooooooooo<'a, Z>,
44 {
45     fn foo() {
46         "hi"
47     }
48 }
49
50 impl<'a, 'b, X, Y: Foo<Bar>> Foo<'a, X> for Bar<'b, Y>
51 where
52     X: Foooooooooooooooooooooooooooo<'a, Z>,
53 {
54     fn foo() {
55         "hi"
56     }
57 }
58
59 impl<T> Foo for Bar<T> where T: Baz {}
60
61 impl<T> Foo for Bar<T>
62 where
63     T: Baz,
64 {
65     // Comment
66 }
67
68 impl Foo {
69     fn foo() {}
70 }
71
72 impl Boo {
73     // BOO
74     fn boo() {}
75     // FOO
76 }
77
78 mod a {
79     impl Foo {
80         // Hello!
81         fn foo() {}
82     }
83 }
84
85 mod b {
86     mod a {
87         impl Foo {
88             fn foo() {}
89         }
90     }
91 }
92
93 impl Foo {
94     add_fun!();
95 }
96
97 impl Blah {
98     fn boop() {}
99     add_fun!();
100 }
101
102 impl X {
103     fn do_parse(mut self: X) {}
104 }
105
106 impl Y5000 {
107     fn bar(self: X<'a, 'b>, y: Y) {}
108
109     fn bad(&self, (x, y): CoorT) {}
110
111     fn turbo_bad(self: X<'a, 'b>, (x, y): CoorT) {}
112 }
113
114 pub impl<T> Foo for Bar<T>
115 where
116     T: Foo,
117 {
118     fn foo() {
119         "hi"
120     }
121 }
122
123 pub impl<T, Z> Foo for Bar<T, Z>
124 where
125     T: Foo,
126     Z: Baz,
127 {
128 }
129
130 mod m {
131     impl<T> PartialEq for S<T>
132     where
133         T: PartialEq,
134     {
135         fn eq(&self, other: &Self) {
136             true
137         }
138     }
139
140     impl<T> PartialEq for S<T> where T: PartialEq {}
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 }
233
234 // #2746
235 impl<'seq1, 'seq2, 'body, 'scope, Channel>
236     Adc12<
237         Dual,
238         MasterRunningDma<'seq1, 'body, 'scope, Channel>,
239         SlaveRunningDma<'seq2, 'body, 'scope>,
240     >
241 where
242     Channel: DmaChannel,
243 {
244 }
245
246 // #4084
247 impl const std::default::Default for Struct {
248     #[inline]
249     fn default() -> Self {
250         Self { f: 12.5 }
251     }
252 }