]> git.lizzy.rs Git - rust.git/blob - tests/target/enum.rs
Merge pull request #1769 from topecongiro/comment-vertical-alignment
[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 { a: A },
50 }
51
52 enum X {
53     CreateWebGLPaintTask(
54         Size2D<i32>,
55         GLContextAttributes,
56         IpcSender<Result<(IpcSender<CanvasMsg>, usize), String>>,
57     ), // This is a post comment
58 }
59
60 pub enum EnumWithAttributes {
61     // This is a pre comment
62     // AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
63     TupleVar(usize, usize, usize), /* AAAA AAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAA
64                                     * AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA */
65     // Pre Comment
66     #[rustfmt_skip]
67     SkippedItem(String,String,), // Post-comment
68     #[another_attr]
69     #[attr2]
70     ItemStruct { x: usize, y: usize }, /* Comment AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA */
71     // And another
72     ForcedPreflight, /* AAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
73                       * AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA */
74 }
75
76 pub enum SingleTuple {
77     // Pre Comment AAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
78     // AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
79     Match(usize, usize, String), /* Post-comment AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA */
80 }
81
82 pub enum SingleStruct {
83     Match { name: String, loc: usize }, // Post-comment
84 }
85
86 pub enum GenericEnum<I, T>
87 where
88     I: Iterator<Item = T>,
89 {
90     // Pre Comment
91     Left { list: I, root: T },  // Post-comment
92     Right { list: I, root: T }, // Post Comment
93 }
94
95
96 enum EmtpyWithComment {
97     // Some comment
98 }
99
100 enum TestFormatFails {
101     AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
102 }
103
104 fn nested_enum_test() {
105     if true {
106         enum TestEnum {
107             One(
108                 usize,
109                 usize,
110                 usize,
111                 usize,
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             ), /* AAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAA
125                 * AAAAAAAAAAAAAAAAAAAAAA */
126             Two, /* AAAAAAAAAAAAAAAAAA  AAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
127                   * AAAAAAAAAAAAAAAAAA */
128         }
129         enum TestNestedFormatFail {
130             AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
131         }
132     }
133 }
134
135 pub struct EmtpyWithComment {
136     // FIXME: Implement this struct
137 }
138
139 // #1115
140 pub enum Bencoding<'i> {
141     Str(&'i [u8]),
142     Int(i64),
143     List(Vec<Bencoding<'i>>),
144     /// A bencoded dict value. The first element the slice of bytes in the
145     /// source that the dict is
146     /// composed of. The second is the dict, decoded into an ordered map.
147     // TODO make Dict "structlike" AKA name the two values.
148     Dict(&'i [u8], BTreeMap<&'i [u8], Bencoding<'i>>),
149 }
150
151 // #1261
152 pub enum CoreResourceMsg {
153     SetCookieForUrl(
154         ServoUrl,
155         #[serde(deserialize_with = "::hyper_serde::deserialize",
156                 serialize_with = "::hyper_serde::serialize")]
157         Cookie,
158         CookieSource,
159     ),
160 }