]> git.lizzy.rs Git - rust.git/blob - tests/target/enum.rs
Merge pull request #2396 from topecongiro/issue-2389
[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)]
28     B = 2, // comment
29     C,
30 }
31
32 enum LongVariants {
33     First(
34         LOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOONG, // comment
35         VARIANT,
36     ),
37     // This is the second variant
38     Second,
39 }
40
41 enum StructLikeVariants {
42     Normal(u32, String),
43     StructLike {
44         x: i32, // Test comment
45         // Pre-comment
46         #[Attr50]
47         y: SomeType, // Aanother Comment
48     },
49     SL {
50         a: A,
51     },
52 }
53
54 enum X {
55     CreateWebGLPaintTask(
56         Size2D<i32>,
57         GLContextAttributes,
58         IpcSender<Result<(IpcSender<CanvasMsg>, usize), String>>,
59     ), // This is a post comment
60 }
61
62 pub enum EnumWithAttributes {
63     //This is a pre comment
64     // AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
65     TupleVar(usize, usize, usize), /* AAAA AAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAA
66                                     * AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA */
67     // Pre Comment
68     #[rustfmt_skip]
69     SkippedItem(String,String,), // Post-comment
70     #[another_attr]
71     #[attr2]
72     ItemStruct {
73         x: usize,
74         y: usize,
75     }, /* Comment AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA */
76     // And another
77     ForcedPreflight, /* AAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
78                       * AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA */
79 }
80
81 pub enum SingleTuple {
82     // Pre Comment AAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
83     // AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
84     Match(usize, usize, String), /* Post-comment AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA */
85 }
86
87 pub enum SingleStruct {
88     Match { name: String, loc: usize }, // Post-comment
89 }
90
91 pub enum GenericEnum<I, T>
92 where
93     I: Iterator<Item = T>,
94 {
95     // Pre Comment
96     Left { list: I, root: T },  // Post-comment
97     Right { list: I, root: T }, // Post Comment
98 }
99
100 enum EmtpyWithComment {
101     // Some comment
102 }
103
104 enum TestFormatFails {
105     AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
106 }
107
108 fn nested_enum_test() {
109     if true {
110         enum TestEnum {
111             One(
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                 usize,
127                 usize,
128             ), /* AAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAA
129                 * AAAAAAAAAAAAAAAAAAAAAA */
130             Two, /* AAAAAAAAAAAAAAAAAA  AAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
131                   * AAAAAAAAAAAAAAAAAA */
132         }
133         enum TestNestedFormatFail {
134             AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
135         }
136     }
137 }
138
139 pub struct EmtpyWithComment {
140     // FIXME: Implement this struct
141 }
142
143 // #1115
144 pub enum Bencoding<'i> {
145     Str(&'i [u8]),
146     Int(i64),
147     List(Vec<Bencoding<'i>>),
148     /// A bencoded dict value. The first element the slice of bytes in the source that the dict is
149     /// composed of. The second is the dict, decoded into an ordered map.
150     // TODO make Dict "structlike" AKA name the two values.
151     Dict(&'i [u8], BTreeMap<&'i [u8], Bencoding<'i>>),
152 }
153
154 // #1261
155 pub enum CoreResourceMsg {
156     SetCookieForUrl(
157         ServoUrl,
158         #[serde(deserialize_with = "::hyper_serde::deserialize",
159                 serialize_with = "::hyper_serde::serialize")]
160         Cookie,
161         CookieSource,
162     ),
163 }
164
165 enum Loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong
166 {}
167 enum Looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong
168 {}
169 enum Loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong
170 {}
171 enum Loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong
172 {
173     Foo,
174 }
175
176 // #1046
177 pub enum Entry<'a, K: 'a, V: 'a> {
178     Vacant(#[stable(feature = "rust1", since = "1.0.0")] VacantEntry<'a, K, V>),
179     Occupied(#[stable(feature = "rust1", since = "1.0.0")] OccupiedEntry<'a, K, V>),
180 }
181
182 // #2081
183 pub enum ForegroundColor {
184     CYAN =
185         (winapi::FOREGROUND_INTENSITY | winapi::FOREGROUND_GREEN | winapi::FOREGROUND_BLUE) as u16,
186 }
187
188 // #2098
189 pub enum E<'a> {
190     V(<std::slice::Iter<'a, Xxxxxxxxxxxxxx> as Iterator>::Item),
191 }
192
193 // #1809
194 enum State {
195     TryRecv {
196         pos: usize,
197         lap: u8,
198         closed_count: usize,
199     },
200     Subscribe {
201         pos: usize,
202     },
203     IsReady {
204         pos: usize,
205         ready: bool,
206     },
207     Unsubscribe {
208         pos: usize,
209         lap: u8,
210         id_woken: usize,
211     },
212     FinalTryRecv {
213         pos: usize,
214         id_woken: usize,
215     },
216     TimedOut,
217     Disconnected,
218 }
219
220 // #2190
221 #[derive(Debug, Fail)]
222 enum AnError {
223     #[fail(display = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")]
224     UnexpectedSingleToken { token: syn::Token },
225 }
226
227 // #2193
228 enum WidthOf101 {
229     #[fail(display = ".....................................................")]
230     Io(::std::io::Error),
231     #[fail(display = ".....................................................")]
232     Ioo(::std::io::Error),
233     Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(::std::io::Error),
234     Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(
235         ::std::io::Error,
236     ),
237 }
238
239 // #2389
240 pub enum QlError {
241     #[fail(display = "Parsing error: {}", 0)]
242     LexError(parser::lexer::LexError),
243     #[fail(display = "Parsing error: {:?}", 0)]
244     ParseError(parser::ParseError),
245     #[fail(display = "Validation error: {:?}", 0)]
246     ValidationError(Vec<validation::Error>),
247     #[fail(display = "Execution error: {}", 0)]
248     ExecutionError(String),
249     // (from, to)
250     #[fail(display = "Translation error: from {} to {}", 0, 1)]
251     TranslationError(String, String),
252     // (kind, input, expected)
253     #[fail(display = "Could not find {}: Found: {}, expected: {:?}", 0, 1, 2)]
254     ResolveError(&'static str, String, Option<String>),
255 }