]> git.lizzy.rs Git - rust.git/blob - src/test/debuginfo/tuple-in-struct.rs
Auto merge of #68528 - ecstatic-morse:maybe-init-variants, r=oli-obk
[rust.git] / src / test / debuginfo / tuple-in-struct.rs
1 // ignore-tidy-linelength
2
3 // min-lldb-version: 310
4
5 // compile-flags:-g
6
7 // gdb-command:run
8
9 // gdb-command:print no_padding1
10 // gdbg-check:$1 = {x = {__0 = 0, __1 = 1}, y = 2, z = {__0 = 3, __1 = 4, __2 = 5}}
11 // gdbr-check:$1 = tuple_in_struct::NoPadding1 {x: (0, 1), y: 2, z: (3, 4, 5)}
12 // gdb-command:print no_padding2
13 // gdbg-check:$2 = {x = {__0 = 6, __1 = 7}, y = {__0 = {__0 = 8, __1 = 9}, __1 = 10}}
14 // gdbr-check:$2 = tuple_in_struct::NoPadding2 {x: (6, 7), y: ((8, 9), 10)}
15
16 // gdb-command:print tuple_internal_padding
17 // gdbg-check:$3 = {x = {__0 = 11, __1 = 12}, y = {__0 = 13, __1 = 14}}
18 // gdbr-check:$3 = tuple_in_struct::TupleInternalPadding {x: (11, 12), y: (13, 14)}
19 // gdb-command:print struct_internal_padding
20 // gdbg-check:$4 = {x = {__0 = 15, __1 = 16}, y = {__0 = 17, __1 = 18}}
21 // gdbr-check:$4 = tuple_in_struct::StructInternalPadding {x: (15, 16), y: (17, 18)}
22 // gdb-command:print both_internally_padded
23 // gdbg-check:$5 = {x = {__0 = 19, __1 = 20, __2 = 21}, y = {__0 = 22, __1 = 23}}
24 // gdbr-check:$5 = tuple_in_struct::BothInternallyPadded {x: (19, 20, 21), y: (22, 23)}
25
26 // gdb-command:print single_tuple
27 // gdbg-check:$6 = {x = {__0 = 24, __1 = 25, __2 = 26}}
28 // gdbr-check:$6 = tuple_in_struct::SingleTuple {x: (24, 25, 26)}
29
30 // gdb-command:print tuple_padded_at_end
31 // gdbg-check:$7 = {x = {__0 = 27, __1 = 28}, y = {__0 = 29, __1 = 30}}
32 // gdbr-check:$7 = tuple_in_struct::TuplePaddedAtEnd {x: (27, 28), y: (29, 30)}
33 // gdb-command:print struct_padded_at_end
34 // gdbg-check:$8 = {x = {__0 = 31, __1 = 32}, y = {__0 = 33, __1 = 34}}
35 // gdbr-check:$8 = tuple_in_struct::StructPaddedAtEnd {x: (31, 32), y: (33, 34)}
36 // gdb-command:print both_padded_at_end
37 // gdbg-check:$9 = {x = {__0 = 35, __1 = 36, __2 = 37}, y = {__0 = 38, __1 = 39}}
38 // gdbr-check:$9 = tuple_in_struct::BothPaddedAtEnd {x: (35, 36, 37), y: (38, 39)}
39
40 // gdb-command:print mixed_padding
41 // gdbg-check:$10 = {x = {__0 = {__0 = 40, __1 = 41, __2 = 42}, __1 = {__0 = 43, __1 = 44}}, y = {__0 = 45, __1 = 46, __2 = 47, __3 = 48}}
42 // gdbr-check:$10 = tuple_in_struct::MixedPadding {x: ((40, 41, 42), (43, 44)), y: (45, 46, 47, 48)}
43
44 #![allow(unused_variables)]
45 #![feature(omit_gdb_pretty_printer_section)]
46 #![omit_gdb_pretty_printer_section]
47
48 struct NoPadding1 {
49     x: (i32, i32),
50     y: i32,
51     z: (i32, i32, i32)
52 }
53
54 struct NoPadding2 {
55     x: (i32, i32),
56     y: ((i32, i32), i32)
57 }
58
59 struct TupleInternalPadding {
60     x: (i16, i32),
61     y: (i32, i64)
62 }
63
64 struct StructInternalPadding {
65     x: (i16, i16),
66     y: (i64, i64)
67 }
68
69 struct BothInternallyPadded {
70     x: (i16, i32, i32),
71     y: (i32, i64)
72 }
73
74 struct SingleTuple {
75     x: (i16, i32, i64)
76 }
77
78 struct TuplePaddedAtEnd {
79     x: (i32, i16),
80     y: (i64, i32)
81 }
82
83 struct StructPaddedAtEnd {
84     x: (i64, i64),
85     y: (i16, i16)
86 }
87
88 struct BothPaddedAtEnd {
89     x: (i32, i32, i16),
90     y: (i64, i32)
91 }
92
93 // Data-layout (padding signified by dots, one column = 2 bytes):
94 // [a.bbc...ddddee..ffffg.hhi...]
95 struct MixedPadding {
96     x: ((i16, i32, i16), (i64, i32)),
97     y: (i64, i16, i32, i16)
98 }
99
100
101 fn main() {
102     let no_padding1 = NoPadding1 {
103         x: (0, 1),
104         y: 2,
105         z: (3, 4, 5)
106     };
107
108     let no_padding2 = NoPadding2 {
109         x: (6, 7),
110         y: ((8, 9), 10)
111     };
112
113     let tuple_internal_padding = TupleInternalPadding {
114         x: (11, 12),
115         y: (13, 14)
116     };
117
118     let struct_internal_padding = StructInternalPadding {
119         x: (15, 16),
120         y: (17, 18)
121     };
122
123     let both_internally_padded = BothInternallyPadded {
124         x: (19, 20, 21),
125         y: (22, 23)
126     };
127
128     let single_tuple = SingleTuple {
129         x: (24, 25, 26)
130     };
131
132     let tuple_padded_at_end = TuplePaddedAtEnd {
133         x: (27, 28),
134         y: (29, 30)
135     };
136
137     let struct_padded_at_end = StructPaddedAtEnd {
138         x: (31, 32),
139         y: (33, 34)
140     };
141
142     let both_padded_at_end = BothPaddedAtEnd {
143         x: (35, 36, 37),
144         y: (38, 39)
145     };
146
147     let mixed_padding = MixedPadding {
148         x: ((40, 41, 42), (43, 44)),
149         y: (45, 46, 47, 48)
150     };
151
152     zzz(); // #break
153 }
154
155 fn zzz() {()}