]> git.lizzy.rs Git - rust.git/blob - tests/target/enum.rs
Merge pull request #2173 from topecongiro/assignment-with-100-chars
[rust.git] / tests / target / enum.rs
1 // rustfmt-wrap_comments: true
2 // rustfmt-error_on_line_overflow: false
3 // Enums test
4
5 #[atrr]
6 pub enum Test {
7     A,
8     B(u32, A /* comment */, SomeType),
9     /// Doc comment
10     C,
11 }
12
13 pub enum Foo<'a, Y: Baz>
14 where
15     X: Whatever,
16 {
17     A,
18 }
19
20 enum EmtpyWithComment {
21     // Some comment
22 }
23
24 // C-style enum
25 enum Bar {
26     A = 1,
27     #[someAttr(test)] B = 2, // comment
28     C,
29 }
30
31 enum LongVariants {
32     First(
33         LOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOONG, // comment
34         VARIANT,
35     ),
36     // This is the second variant
37     Second,
38 }
39
40 enum StructLikeVariants {
41     Normal(u32, String),
42     StructLike {
43         x: i32, // Test comment
44         // Pre-comment
45         #[Attr50] y: SomeType, // Aanother Comment
46     },
47     SL {
48         a: A,
49     },
50 }
51
52 enum X {
53     CreateWebGLPaintTask(
54         Size2D<i32>,
55         GLContextAttributes,
56         IpcSender<Result<(IpcSender<CanvasMsg>, usize), String>>,
57     ), // This is a post comment
58 }
59
60 pub enum EnumWithAttributes {
61     // This is a pre comment
62     // AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
63     TupleVar(usize, usize, usize), /* AAAA AAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAA
64                                     * AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA */
65     // Pre Comment
66     #[rustfmt_skip]
67     SkippedItem(String,String,), // Post-comment
68     #[another_attr]
69     #[attr2]
70     ItemStruct {
71         x: usize,
72         y: usize,
73     }, /* Comment AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA */
74     // And another
75     ForcedPreflight, /* AAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
76                       * AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA */
77 }
78
79 pub enum SingleTuple {
80     // Pre Comment AAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
81     // AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
82     Match(usize, usize, String), /* Post-comment AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA */
83 }
84
85 pub enum SingleStruct {
86     Match { name: String, loc: usize }, // Post-comment
87 }
88
89 pub enum GenericEnum<I, T>
90 where
91     I: Iterator<Item = T>,
92 {
93     // Pre Comment
94     Left { list: I, root: T },  // Post-comment
95     Right { list: I, root: T }, // Post Comment
96 }
97
98 enum EmtpyWithComment {
99     // Some comment
100 }
101
102 enum TestFormatFails {
103     AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
104 }
105
106 fn nested_enum_test() {
107     if true {
108         enum TestEnum {
109             One(
110                 usize,
111                 usize,
112                 usize,
113                 usize,
114                 usize,
115                 usize,
116                 usize,
117                 usize,
118                 usize,
119                 usize,
120                 usize,
121                 usize,
122                 usize,
123                 usize,
124                 usize,
125                 usize,
126             ), /* AAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAA
127                 * AAAAAAAAAAAAAAAAAAAAAA */
128             Two, /* AAAAAAAAAAAAAAAAAA  AAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
129                   * AAAAAAAAAAAAAAAAAA */
130         }
131         enum TestNestedFormatFail {
132             AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
133         }
134     }
135 }
136
137 pub struct EmtpyWithComment {
138     // FIXME: Implement this struct
139 }
140
141 // #1115
142 pub enum Bencoding<'i> {
143     Str(&'i [u8]),
144     Int(i64),
145     List(Vec<Bencoding<'i>>),
146     /// A bencoded dict value. The first element the slice of bytes in the source that the dict is
147     /// composed of. The second is the dict, decoded into an ordered map.
148     // TODO make Dict "structlike" AKA name the two values.
149     Dict(&'i [u8], BTreeMap<&'i [u8], Bencoding<'i>>),
150 }
151
152 // #1261
153 pub enum CoreResourceMsg {
154     SetCookieForUrl(
155         ServoUrl,
156         #[serde(deserialize_with = "::hyper_serde::deserialize",
157                 serialize_with = "::hyper_serde::serialize")]
158         Cookie,
159         CookieSource,
160     ),
161 }
162
163 enum Loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong
164 {}
165 enum Looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong
166 {}
167 enum Loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong
168 {}
169 enum Loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong
170 {
171     Foo,
172 }
173
174 // #1046
175 pub enum Entry<'a, K: 'a, V: 'a> {
176     Vacant(#[stable(feature = "rust1", since = "1.0.0")] VacantEntry<'a, K, V>),
177     Occupied(#[stable(feature = "rust1", since = "1.0.0")] OccupiedEntry<'a, K, V>),
178 }
179
180 // #2081
181 pub enum ForegroundColor {
182     CYAN =
183         (winapi::FOREGROUND_INTENSITY | winapi::FOREGROUND_GREEN | winapi::FOREGROUND_BLUE) as u16,
184 }
185
186 // #2098
187 pub enum E<'a> {
188     V(<std::slice::Iter<'a, Xxxxxxxxxxxxxx> as Iterator>::Item),
189 }
190
191 // #1809
192 enum State {
193     TryRecv {
194         pos: usize,
195         lap: u8,
196         closed_count: usize,
197     },
198     Subscribe {
199         pos: usize,
200     },
201     IsReady {
202         pos: usize,
203         ready: bool,
204     },
205     Unsubscribe {
206         pos: usize,
207         lap: u8,
208         id_woken: usize,
209     },
210     FinalTryRecv {
211         pos: usize,
212         id_woken: usize,
213     },
214     TimedOut,
215     Disconnected,
216 }
217
218 // #2190
219 #[derive(Debug, Fail)]
220 enum AnError {
221     #[fail(display = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")]
222     UnexpectedSingleToken { token: syn::Token },
223 }
224
225 // #2193
226 enum WidthOf101 {
227     #[fail(display = ".....................................................")] Io(::std::io::Error),
228     #[fail(display = ".....................................................")]
229     Ioo(::std::io::Error),
230     Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(::std::io::Error),
231     Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(
232         ::std::io::Error,
233     ),
234 }