]> git.lizzy.rs Git - rust.git/blob - src/tools/rustfmt/tests/source/impls.rs
Merge commit 'b7f3f7f6082679da2da9a0b3faf1b5adef3afd3b' into clippyup
[rust.git] / src / tools / rustfmt / tests / source / impls.rs
1 // rustfmt-normalize_comments: true
2 impl Foo for Bar { fn foo() { "hi" } }
3
4 pub impl Foo for Bar {
5     // Associated Constants
6     const   Baz:   i32 =   16;
7     // Associated Types
8     type   FooBar  =   usize;
9     // Comment 1
10     fn foo() { "hi" }
11     // Comment 2
12     fn foo() { "hi" }
13     // Comment 3
14 }
15
16 pub unsafe impl<'a, 'b, X, Y: Foo<Bar>> !Foo<'a, X> for Bar<'b, Y> where X: Foo<'a, Z> {
17     fn foo() { "hi" }    
18 }
19
20 impl<'a, 'b, X, Y: Foo<Bar>> Foo<'a, X> for Bar<'b, Y> where X: Fooooooooooooooooooooooooooooo<'a, Z>
21 {
22     fn foo() { "hi" }    
23 }
24
25 impl<'a, 'b, X, Y: Foo<Bar>> Foo<'a, X> for Bar<'b, Y> where X: Foooooooooooooooooooooooooooo<'a, Z>
26 {
27     fn foo() { "hi" }    
28 }
29
30 impl<T> Foo for Bar<T> where T: Baz 
31 {
32 }
33
34 impl<T> Foo for Bar<T> where T: Baz { /* Comment */ }
35
36 impl Foo {
37     fn foo() {}
38 }
39
40 impl Boo {
41
42     // BOO
43     fn boo() {}
44     // FOO
45
46     
47     
48 }
49
50 mod a {
51     impl Foo {
52         // Hello!
53         fn foo() {}
54     }
55 }
56
57
58 mod b {
59     mod a {
60         impl Foo {
61             fn foo() {}
62         }
63     }
64 }
65
66 impl Foo { add_fun!(); }
67
68 impl Blah {
69     fn boop() {}
70     add_fun!();
71 }
72
73 impl X { fn do_parse(  mut  self : X ) {} }
74
75 impl Y5000 {
76     fn bar(self: X< 'a ,  'b >, y: Y) {}
77
78     fn bad(&self, ( x, y): CoorT) {}
79
80     fn turbo_bad(self: X< 'a ,  'b >  , ( x, y): CoorT) {
81         
82     }
83 }
84
85 pub impl<T> Foo for Bar<T> where T: Foo
86 {
87     fn foo() { "hi" }
88 }
89
90 pub impl<T, Z> Foo for Bar<T, Z> where T: Foo, Z: Baz {}
91
92 mod m {
93     impl<T> PartialEq for S<T> where T: PartialEq {
94         fn eq(&self, other: &Self) {
95             true
96         }
97       }
98
99         impl<T> PartialEq for S<T> where T: PartialEq {      }
100  }
101
102 impl<BorrowType, K, V, NodeType, HandleType> Handle<NodeRef<BorrowType, K, V, NodeType>, HandleType> {
103 }
104
105 impl<BorrowType, K, V, NodeType, HandleType> PartialEq for Handle<NodeRef<BorrowType, K, V, NodeType>, HandleType> {
106 }
107
108 mod x {
109     impl<A, B, C, D> Foo
110         where A: 'static,
111               B: 'static,
112               C: 'static,
113               D: 'static { }
114 }
115
116 impl<ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNodeFoo> Issue1249<ConcreteThreadSafeLayoutNode> {
117     // Creates a new flow constructor.
118    fn foo() {}
119 }
120
121 // #1600
122 impl<#[may_dangle] K, #[may_dangle] V> Drop for RawTable<K, V> {
123     fn drop() {}
124 }
125
126 // #1168
127 pub trait Number: Copy + Eq +      Not<Output = Self> + Shl<u8, Output = Self> +
128     Shr<u8, Output = Self>       +
129     BitAnd<Self, Output=Self> +    BitOr<Self, Output=Self>  + BitAndAssign + BitOrAssign
130
131
132
133 {
134     // test
135     fn zero() -> Self;
136 }
137
138 // #1642
139 pub trait SomeTrait : Clone + Eq + PartialEq + Ord + PartialOrd + Default + Hash + Debug + Display + Write + Read + FromStr {
140     // comment
141 }
142
143 // #1995
144 impl Foo {
145     fn f(
146                     S {
147                               aaaaaaaaaa: aaaaaaaaaa,
148                               bbbbbbbbbb: bbbbbbbbbb,
149                               cccccccccc: cccccccccc,
150                     }: S
151     ) -> u32{
152         1
153     }
154 }
155
156 // #2491
157 impl<'a, 'b, 'c> SomeThing<Something> for (&'a mut SomethingLong, &'b mut SomethingLong, &'c mut SomethingLong) {
158     fn foo() {}
159 }
160
161 // #2746
162 impl<'seq1, 'seq2, 'body, 'scope, Channel> Adc12< Dual, MasterRunningDma<'seq1, 'body, 'scope, Channel>, SlaveRunningDma<'seq2, 'body, 'scope>, > where Channel: DmaChannel, {}
163
164 // #4084
165 impl     const       std::default::Default for Struct {
166     #[inline]
167     fn default() -> Self {
168         Self { f: 12.5 }
169     }
170 }