]> git.lizzy.rs Git - rust.git/blob - tests/target/enum.rs
Merge pull request #2656 from topecongiro/issue-2594
[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
149     /// source that the dict is composed of. The second is the dict,
150     /// decoded into an ordered map.
151     // TODO make Dict "structlike" AKA name the two values.
152     Dict(&'i [u8], BTreeMap<&'i [u8], Bencoding<'i>>),
153 }
154
155 // #1261
156 pub enum CoreResourceMsg {
157     SetCookieForUrl(
158         ServoUrl,
159         #[serde(
160             deserialize_with = "::hyper_serde::deserialize",
161             serialize_with = "::hyper_serde::serialize"
162         )]
163         Cookie,
164         CookieSource,
165     ),
166 }
167
168 enum Loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong
169 {}
170 enum Looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong
171 {}
172 enum Loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong
173 {}
174 enum Loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong
175 {
176     Foo,
177 }
178
179 // #1046
180 pub enum Entry<'a, K: 'a, V: 'a> {
181     Vacant(#[stable(feature = "rust1", since = "1.0.0")] VacantEntry<'a, K, V>),
182     Occupied(#[stable(feature = "rust1", since = "1.0.0")] OccupiedEntry<'a, K, V>),
183 }
184
185 // #2081
186 pub enum ForegroundColor {
187     CYAN =
188         (winapi::FOREGROUND_INTENSITY | winapi::FOREGROUND_GREEN | winapi::FOREGROUND_BLUE) as u16,
189 }
190
191 // #2098
192 pub enum E<'a> {
193     V(<std::slice::Iter<'a, Xxxxxxxxxxxxxx> as Iterator>::Item),
194 }
195
196 // #1809
197 enum State {
198     TryRecv {
199         pos: usize,
200         lap: u8,
201         closed_count: usize,
202     },
203     Subscribe {
204         pos: usize,
205     },
206     IsReady {
207         pos: usize,
208         ready: bool,
209     },
210     Unsubscribe {
211         pos: usize,
212         lap: u8,
213         id_woken: usize,
214     },
215     FinalTryRecv {
216         pos: usize,
217         id_woken: usize,
218     },
219     TimedOut,
220     Disconnected,
221 }
222
223 // #2190
224 #[derive(Debug, Fail)]
225 enum AnError {
226     #[fail(
227         display = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
228     )]
229     UnexpectedSingleToken { token: syn::Token },
230 }
231
232 // #2193
233 enum WidthOf101 {
234     #[fail(display = ".....................................................")]
235     Io(::std::io::Error),
236     #[fail(display = ".....................................................")]
237     Ioo(::std::io::Error),
238     Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(::std::io::Error),
239     Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(
240         ::std::io::Error,
241     ),
242 }
243
244 // #2389
245 pub enum QlError {
246     #[fail(display = "Parsing error: {}", 0)]
247     LexError(parser::lexer::LexError),
248     #[fail(display = "Parsing error: {:?}", 0)]
249     ParseError(parser::ParseError),
250     #[fail(display = "Validation error: {:?}", 0)]
251     ValidationError(Vec<validation::Error>),
252     #[fail(display = "Execution error: {}", 0)]
253     ExecutionError(String),
254     // (from, to)
255     #[fail(display = "Translation error: from {} to {}", 0, 1)]
256     TranslationError(String, String),
257     // (kind, input, expected)
258     #[fail(display = "Could not find {}: Found: {}, expected: {:?}", 0, 1, 2)]
259     ResolveError(&'static str, String, Option<String>),
260 }
261
262 // #2594
263 enum Foo {}
264 enum Bar {}