summaryrefslogtreecommitdiffstats
path: root/src/tools/rustfmt/tests/target/enum.rs
blob: 9a25126b44ecb49888e74c358e95382a822c9528 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
// rustfmt-wrap_comments: true
// Enums test

#[atrr]
pub enum Test {
    A,
    B(u32, A /* comment */, SomeType),
    /// Doc comment
    C,
}

pub enum Foo<'a, Y: Baz>
where
    X: Whatever,
{
    A,
}

enum EmtpyWithComment {
    // Some comment
}

// C-style enum
enum Bar {
    A = 1,
    #[someAttr(test)]
    B = 2, // comment
    C,
}

enum LongVariants {
    First(
        LOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOONG, // comment
        VARIANT,
    ),
    // This is the second variant
    Second,
}

enum StructLikeVariants {
    Normal(u32, String),
    StructLike {
        x: i32, // Test comment
        // Pre-comment
        #[Attr50]
        y: SomeType, // Aanother Comment
    },
    SL {
        a: A,
    },
}

enum X {
    CreateWebGLPaintTask(
        Size2D<i32>,
        GLContextAttributes,
        IpcSender<Result<(IpcSender<CanvasMsg>, usize), String>>,
    ), // This is a post comment
}

pub enum EnumWithAttributes {
    //This is a pre comment
    // AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    TupleVar(usize, usize, usize), /* AAAA AAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAA
                                    * AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA */
    // Pre Comment
    #[rustfmt::skip]
    SkippedItem(String,String,), // Post-comment
    #[another_attr]
    #[attr2]
    ItemStruct {
        x: usize,
        y: usize,
    }, /* Comment AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA */
    // And another
    ForcedPreflight, /* AAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
                      * AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA */
}

pub enum SingleTuple {
    // Pre Comment AAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    // AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    Match(usize, usize, String), /* Post-comment AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA */
}

pub enum SingleStruct {
    Match { name: String, loc: usize }, // Post-comment
}

pub enum GenericEnum<I, T>
where
    I: Iterator<Item = T>,
{
    // Pre Comment
    Left { list: I, root: T },  // Post-comment
    Right { list: I, root: T }, // Post Comment
}

enum EmtpyWithComment {
    // Some comment
}

enum TestFormatFails {
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
}

fn nested_enum_test() {
    if true {
        enum TestEnum {
            One(
                usize,
                usize,
                usize,
                usize,
                usize,
                usize,
                usize,
                usize,
                usize,
                usize,
                usize,
                usize,
                usize,
                usize,
                usize,
                usize,
            ), /* AAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAA
                * AAAAAAAAAAAAAAAAAAAAAA */
            Two, /* AAAAAAAAAAAAAAAAAA  AAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
                  * AAAAAAAAAAAAAAAAAA */
        }
        enum TestNestedFormatFail {
            AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
        }
    }
}

pub struct EmtpyWithComment {
    // FIXME: Implement this struct
}

// #1115
pub enum Bencoding<'i> {
    Str(&'i [u8]),
    Int(i64),
    List(Vec<Bencoding<'i>>),
    /// A bencoded dict value. The first element the slice of bytes in the
    /// source that the dict is composed of. The second is the dict, decoded
    /// into an ordered map.
    // TODO make Dict "structlike" AKA name the two values.
    Dict(&'i [u8], BTreeMap<&'i [u8], Bencoding<'i>>),
}

// #1261
pub enum CoreResourceMsg {
    SetCookieForUrl(
        ServoUrl,
        #[serde(
            deserialize_with = "::hyper_serde::deserialize",
            serialize_with = "::hyper_serde::serialize"
        )]
        Cookie,
        CookieSource,
    ),
}

enum Loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong
{}
enum Looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong
{}
enum Loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong
{}
enum Loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong
{
    Foo,
}

// #1046
pub enum Entry<'a, K: 'a, V: 'a> {
    Vacant(#[stable(feature = "rust1", since = "1.0.0")] VacantEntry<'a, K, V>),
    Occupied(#[stable(feature = "rust1", since = "1.0.0")] OccupiedEntry<'a, K, V>),
}

// #2081
pub enum ForegroundColor {
    CYAN =
        (winapi::FOREGROUND_INTENSITY | winapi::FOREGROUND_GREEN | winapi::FOREGROUND_BLUE) as u16,
}

// #2098
pub enum E<'a> {
    V(<std::slice::Iter<'a, Xxxxxxxxxxxxxx> as Iterator>::Item),
}

// #1809
enum State {
    TryRecv {
        pos: usize,
        lap: u8,
        closed_count: usize,
    },
    Subscribe {
        pos: usize,
    },
    IsReady {
        pos: usize,
        ready: bool,
    },
    Unsubscribe {
        pos: usize,
        lap: u8,
        id_woken: usize,
    },
    FinalTryRecv {
        pos: usize,
        id_woken: usize,
    },
    TimedOut,
    Disconnected,
}

// #2190
#[derive(Debug, Fail)]
enum AnError {
    #[fail(
        display = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    )]
    UnexpectedSingleToken { token: syn::Token },
}

// #2193
enum WidthOf101 {
    #[fail(display = ".....................................................")]
    Io(::std::io::Error),
    #[fail(display = ".....................................................")]
    Ioo(::std::io::Error),
    Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(::std::io::Error),
    Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(
        ::std::io::Error,
    ),
}

// #2389
pub enum QlError {
    #[fail(display = "Parsing error: {}", 0)]
    LexError(parser::lexer::LexError),
    #[fail(display = "Parsing error: {:?}", 0)]
    ParseError(parser::ParseError),
    #[fail(display = "Validation error: {:?}", 0)]
    ValidationError(Vec<validation::Error>),
    #[fail(display = "Execution error: {}", 0)]
    ExecutionError(String),
    // (from, to)
    #[fail(display = "Translation error: from {} to {}", 0, 1)]
    TranslationError(String, String),
    // (kind, input, expected)
    #[fail(
        display = "aaaaaaaaaaaaCould not find {}: Found: {}, expected: {:?}",
        0, 1, 2
    )]
    ResolveError(&'static str, String, Option<String>),
}

// #2594
enum Foo {}
enum Bar {}

// #3562
enum PublishedFileVisibility {
    Public =
        sys::ERemoteStoragePublishedFileVisibility_k_ERemoteStoragePublishedFileVisibilityPublic,
    FriendsOnly = sys::ERemoteStoragePublishedFileVisibility_k_ERemoteStoragePublishedFileVisibilityFriendsOnly,
    Private =
        sys::ERemoteStoragePublishedFileVisibility_k_ERemoteStoragePublishedFileVisibilityPrivate,
}

// #3771
//#![feature(arbitrary_enum_discriminant)]
#[repr(u32)]
pub enum E {
    A {
        a: u32,
    } = 0x100,
    B {
        field1: u32,
        field2: u8,
        field3: m::M,
    } = 0x300, // comment
}