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