]> git.lizzy.rs Git - rust.git/blob - tests/target/impls.rs
Merge pull request #2519 from topecongiro/nested-parens
[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     // test
188     fn zero() -> Self;
189 }
190
191 // #1642
192 pub trait SomeTrait
193     : Clone
194     + Eq
195     + PartialEq
196     + Ord
197     + PartialOrd
198     + Default
199     + Hash
200     + Debug
201     + Display
202     + Write
203     + Read
204     + FromStr {
205     // comment
206 }
207
208 // #1995
209 impl Foo {
210     fn f(
211         S {
212             aaaaaaaaaa: aaaaaaaaaa,
213             bbbbbbbbbb: bbbbbbbbbb,
214             cccccccccc: cccccccccc,
215         }: S,
216     ) -> u32 {
217         1
218     }
219 }
220
221 // #2491
222 impl<'a, 'b, 'c> SomeThing<Something>
223     for (
224         &'a mut SomethingLong,
225         &'b mut SomethingLong,
226         &'c mut SomethingLong,
227     )
228 {
229     fn foo() {}
230 }