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