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