]> git.lizzy.rs Git - rust.git/blob - src/test/debuginfo/destructured-local.rs
Auto merge of #28816 - petrochenkov:unistruct, r=nrc
[rust.git] / src / test / debuginfo / destructured-local.rs
1 // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // min-lldb-version: 310
12
13 // compile-flags:-g
14
15 // === GDB TESTS ===================================================================================
16
17 // gdb-command:run
18
19 // gdb-command:print a
20 // gdb-check:$1 = 1
21 // gdb-command:print b
22 // gdb-check:$2 = false
23
24 // gdb-command:print c
25 // gdb-check:$3 = 2
26 // gdb-command:print d
27 // gdb-check:$4 = 3
28 // gdb-command:print e
29 // gdb-check:$5 = 4
30
31 // gdb-command:print f
32 // gdb-check:$6 = 5
33 // gdb-command:print g
34 // gdb-check:$7 = {__0 = 6, __1 = 7}
35
36 // gdb-command:print h
37 // gdb-check:$8 = 8
38 // gdb-command:print i
39 // gdb-check:$9 = {a = 9, b = 10}
40 // gdb-command:print j
41 // gdb-check:$10 = 11
42
43 // gdb-command:print k
44 // gdb-check:$11 = 12
45 // gdb-command:print l
46 // gdb-check:$12 = 13
47
48 // gdb-command:print m
49 // gdb-check:$13 = 14
50 // gdb-command:print n
51 // gdb-check:$14 = 16
52
53 // gdb-command:print o
54 // gdb-check:$15 = 18
55
56 // gdb-command:print p
57 // gdb-check:$16 = 19
58 // gdb-command:print q
59 // gdb-check:$17 = 20
60 // gdb-command:print r
61 // gdb-check:$18 = {a = 21, b = 22}
62
63 // gdb-command:print s
64 // gdb-check:$19 = 24
65 // gdb-command:print t
66 // gdb-check:$20 = 23
67
68 // gdb-command:print u
69 // gdb-check:$21 = 25
70 // gdb-command:print v
71 // gdb-check:$22 = 26
72 // gdb-command:print w
73 // gdb-check:$23 = 27
74 // gdb-command:print x
75 // gdb-check:$24 = 28
76 // gdb-command:print y
77 // gdb-check:$25 = 29
78 // gdb-command:print z
79 // gdb-check:$26 = 30
80 // gdb-command:print ae
81 // gdb-check:$27 = 31
82 // gdb-command:print oe
83 // gdb-check:$28 = 32
84 // gdb-command:print ue
85 // gdb-check:$29 = 33
86
87 // gdb-command:print aa
88 // gdb-check:$30 = {__0 = 34, __1 = 35}
89
90 // gdb-command:print bb
91 // gdb-check:$31 = {__0 = 36, __1 = 37}
92
93 // gdb-command:print cc
94 // gdb-check:$32 = 38
95
96 // gdb-command:print dd
97 // gdb-check:$33 = {__0 = 40, __1 = 41, __2 = 42}
98
99 // gdb-command:print *ee
100 // gdb-check:$34 = {__0 = 43, __1 = 44, __2 = 45}
101
102 // gdb-command:print *ff
103 // gdb-check:$35 = 46
104
105 // gdb-command:print gg
106 // gdb-check:$36 = {__0 = 47, __1 = 48}
107
108 // gdb-command:print *hh
109 // gdb-check:$37 = 50
110
111 // gdb-command:print ii
112 // gdb-check:$38 = 51
113
114 // gdb-command:print *jj
115 // gdb-check:$39 = 52
116
117 // gdb-command:print kk
118 // gdb-check:$40 = 53
119
120 // gdb-command:print ll
121 // gdb-check:$41 = 54
122
123 // gdb-command:print mm
124 // gdb-check:$42 = 55
125
126 // gdb-command:print *nn
127 // gdb-check:$43 = 56
128
129
130 // === LLDB TESTS ==================================================================================
131
132 // lldb-command:run
133
134 // lldb-command:print a
135 // lldb-check:[...]$0 = 1
136 // lldb-command:print b
137 // lldb-check:[...]$1 = false
138
139 // lldb-command:print c
140 // lldb-check:[...]$2 = 2
141 // lldb-command:print d
142 // lldb-check:[...]$3 = 3
143 // lldb-command:print e
144 // lldb-check:[...]$4 = 4
145
146 // lldb-command:print f
147 // lldb-check:[...]$5 = 5
148 // lldb-command:print g
149 // lldb-check:[...]$6 = (6, 7)
150
151 // lldb-command:print h
152 // lldb-check:[...]$7 = 8
153 // lldb-command:print i
154 // lldb-check:[...]$8 = Struct { a: 9, b: 10 }
155 // lldb-command:print j
156 // lldb-check:[...]$9 = 11
157
158 // lldb-command:print k
159 // lldb-check:[...]$10 = 12
160 // lldb-command:print l
161 // lldb-check:[...]$11 = 13
162
163 // lldb-command:print m
164 // lldb-check:[...]$12 = 14
165 // lldb-command:print n
166 // lldb-check:[...]$13 = 16
167
168 // lldb-command:print o
169 // lldb-check:[...]$14 = 18
170
171 // lldb-command:print p
172 // lldb-check:[...]$15 = 19
173 // lldb-command:print q
174 // lldb-check:[...]$16 = 20
175 // lldb-command:print r
176 // lldb-check:[...]$17 = Struct { a: 21, b: 22 }
177
178 // lldb-command:print s
179 // lldb-check:[...]$18 = 24
180 // lldb-command:print t
181 // lldb-check:[...]$19 = 23
182
183 // lldb-command:print u
184 // lldb-check:[...]$20 = 25
185 // lldb-command:print v
186 // lldb-check:[...]$21 = 26
187 // lldb-command:print w
188 // lldb-check:[...]$22 = 27
189 // lldb-command:print x
190 // lldb-check:[...]$23 = 28
191 // lldb-command:print y
192 // lldb-check:[...]$24 = 29
193 // lldb-command:print z
194 // lldb-check:[...]$25 = 30
195 // lldb-command:print ae
196 // lldb-check:[...]$26 = 31
197 // lldb-command:print oe
198 // lldb-check:[...]$27 = 32
199 // lldb-command:print ue
200 // lldb-check:[...]$28 = 33
201
202 // lldb-command:print aa
203 // lldb-check:[...]$29 = (34, 35)
204
205 // lldb-command:print bb
206 // lldb-check:[...]$30 = (36, 37)
207
208 // lldb-command:print cc
209 // lldb-check:[...]$31 = 38
210
211 // lldb-command:print dd
212 // lldb-check:[...]$32 = (40, 41, 42)
213
214 // lldb-command:print *ee
215 // lldb-check:[...]$33 = (43, 44, 45)
216
217 // lldb-command:print *ff
218 // lldb-check:[...]$34 = 46
219
220 // lldb-command:print gg
221 // lldb-check:[...]$35 = (47, 48)
222
223 // lldb-command:print *hh
224 // lldb-check:[...]$36 = 50
225
226 // lldb-command:print ii
227 // lldb-check:[...]$37 = 51
228
229 // lldb-command:print *jj
230 // lldb-check:[...]$38 = 52
231
232 // lldb-command:print kk
233 // lldb-check:[...]$39 = 53
234
235 // lldb-command:print ll
236 // lldb-check:[...]$40 = 54
237
238 // lldb-command:print mm
239 // lldb-check:[...]$41 = 55
240
241 // lldb-command:print *nn
242 // lldb-check:[...]$42 = 56
243
244
245 #![allow(unused_variables)]
246 #![feature(box_patterns)]
247 #![feature(box_syntax)]
248 #![feature(omit_gdb_pretty_printer_section)]
249 #![omit_gdb_pretty_printer_section]
250
251 use self::Univariant::Unit;
252
253 struct Struct {
254     a: i64,
255     b: i32
256 }
257
258 enum Univariant {
259     Unit(i32)
260 }
261
262 struct TupleStruct (f64, isize);
263
264
265 fn main() {
266     // simple tuple
267     let (a, b) : (isize, bool) = (1, false);
268
269     // nested tuple
270     let (c, (d, e)) : (isize, (u16, u16)) = (2, (3, 4));
271
272     // bind tuple-typed value to one name (destructure only first level)
273     let (f, g) : (isize, (u32, u32)) = (5, (6, 7));
274
275     // struct as tuple element
276     let (h, i, j) : (i16, Struct, i16) = (8, Struct { a: 9, b: 10 }, 11);
277
278     // struct pattern
279     let Struct { a: k, b: l } = Struct { a: 12, b: 13 };
280
281     // ignored tuple element
282     let (m, _, n) = (14, 15, 16);
283
284     // ignored struct field
285     let Struct { b: o, .. } = Struct { a: 17, b: 18 };
286
287     // one struct destructured, one not
288     let (Struct { a: p, b: q }, r) = (Struct { a: 19, b: 20 }, Struct { a: 21, b: 22 });
289
290     // different order of struct fields
291     let Struct { b: s, a: t } = Struct { a: 23, b: 24 };
292
293     // complex nesting
294     let ((u, v), ((w, (x, Struct { a: y, b: z})), Struct { a: ae, b: oe }), ue) =
295         ((25, 26), ((27, (28, Struct { a: 29, b: 30})), Struct { a: 31, b: 32 }), 33);
296
297     // reference
298     let &aa = &(34, 35);
299
300     // reference
301     let &bb = &(36, 37);
302
303     // contained reference
304     let (&cc, _) = (&38, 39);
305
306     // unique pointer
307     let box dd = box (40, 41, 42);
308
309     // ref binding
310     let ref ee = (43, 44, 45);
311
312     // ref binding in tuple
313     let (ref ff, gg) = (46, (47, 48));
314
315     // ref binding in struct
316     let Struct { b: ref hh, .. } = Struct { a: 49, b: 50 };
317
318     // univariant enum
319     let Unit(ii) = Unit(51);
320
321     // univariant enum with ref      binding
322     let &Unit(ref jj) = &Unit(52);
323
324     // tuple struct
325     let &TupleStruct(kk, ll) = &TupleStruct(53.0, 54);
326
327     // tuple struct with ref binding
328     let &TupleStruct(mm, ref nn) = &TupleStruct(55.0, 56);
329
330     zzz(); // #break
331 }
332
333 fn zzz() { () }