]> git.lizzy.rs Git - rust.git/blob - src/test/debuginfo/destructured-local.rs
Rollup merge of #53506 - phungleson:fix-from-docs-atomic, r=KodrAus
[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 // gdbg-check:$7 = {__0 = 6, __1 = 7}
35 // gdbr-check:$7 = (6, 7)
36
37 // gdb-command:print h
38 // gdb-check:$8 = 8
39 // gdb-command:print i
40 // gdbg-check:$9 = {a = 9, b = 10}
41 // gdbr-check:$9 = destructured_local::Struct {a: 9, b: 10}
42 // gdb-command:print j
43 // gdb-check:$10 = 11
44
45 // gdb-command:print k
46 // gdb-check:$11 = 12
47 // gdb-command:print l
48 // gdb-check:$12 = 13
49
50 // gdb-command:print m
51 // gdb-check:$13 = 14
52 // gdb-command:print n
53 // gdb-check:$14 = 16
54
55 // gdb-command:print o
56 // gdb-check:$15 = 18
57
58 // gdb-command:print p
59 // gdb-check:$16 = 19
60 // gdb-command:print q
61 // gdb-check:$17 = 20
62 // gdb-command:print r
63 // gdbg-check:$18 = {a = 21, b = 22}
64 // gdbr-check:$18 = destructured_local::Struct {a: 21, b: 22}
65
66 // gdb-command:print s
67 // gdb-check:$19 = 24
68 // gdb-command:print t
69 // gdb-check:$20 = 23
70
71 // gdb-command:print u
72 // gdb-check:$21 = 25
73 // gdb-command:print v
74 // gdb-check:$22 = 26
75 // gdb-command:print w
76 // gdb-check:$23 = 27
77 // gdb-command:print x
78 // gdb-check:$24 = 28
79 // gdb-command:print y
80 // gdb-check:$25 = 29
81 // gdb-command:print z
82 // gdb-check:$26 = 30
83 // gdb-command:print ae
84 // gdb-check:$27 = 31
85 // gdb-command:print oe
86 // gdb-check:$28 = 32
87 // gdb-command:print ue
88 // gdb-check:$29 = 33
89
90 // gdb-command:print aa
91 // gdbg-check:$30 = {__0 = 34, __1 = 35}
92 // gdbr-check:$30 = (34, 35)
93
94 // gdb-command:print bb
95 // gdbg-check:$31 = {__0 = 36, __1 = 37}
96 // gdbr-check:$31 = (36, 37)
97
98 // gdb-command:print cc
99 // gdb-check:$32 = 38
100
101 // gdb-command:print dd
102 // gdbg-check:$33 = {__0 = 40, __1 = 41, __2 = 42}
103 // gdbr-check:$33 = (40, 41, 42)
104
105 // gdb-command:print *ee
106 // gdbg-check:$34 = {__0 = 43, __1 = 44, __2 = 45}
107 // gdbr-check:$34 = (43, 44, 45)
108
109 // gdb-command:print *ff
110 // gdb-check:$35 = 46
111
112 // gdb-command:print gg
113 // gdbg-check:$36 = {__0 = 47, __1 = 48}
114 // gdbr-check:$36 = (47, 48)
115
116 // gdb-command:print *hh
117 // gdb-check:$37 = 50
118
119 // gdb-command:print ii
120 // gdb-check:$38 = 51
121
122 // gdb-command:print *jj
123 // gdb-check:$39 = 52
124
125 // gdb-command:print kk
126 // gdb-check:$40 = 53
127
128 // gdb-command:print ll
129 // gdb-check:$41 = 54
130
131 // gdb-command:print mm
132 // gdb-check:$42 = 55
133
134 // gdb-command:print *nn
135 // gdb-check:$43 = 56
136
137
138 // === LLDB TESTS ==================================================================================
139
140 // lldb-command:run
141
142 // lldb-command:print a
143 // lldbg-check:[...]$0 = 1
144 // lldbr-check:(isize) a = 1
145 // lldb-command:print b
146 // lldbg-check:[...]$1 = false
147 // lldbr-check:(bool) b = false
148
149 // lldb-command:print c
150 // lldbg-check:[...]$2 = 2
151 // lldbr-check:(isize) c = 2
152 // lldb-command:print d
153 // lldbg-check:[...]$3 = 3
154 // lldbr-check:(u16) d = 3
155 // lldb-command:print e
156 // lldbg-check:[...]$4 = 4
157 // lldbr-check:(u16) e = 4
158
159 // lldb-command:print f
160 // lldbg-check:[...]$5 = 5
161 // lldbr-check:(isize) f = 5
162 // lldb-command:print g
163 // lldbg-check:[...]$6 = (6, 7)
164 // lldbr-check:((u32, u32)) g = { = 6 = 7 }
165
166 // lldb-command:print h
167 // lldbg-check:[...]$7 = 8
168 // lldbr-check:(i16) h = 8
169 // lldb-command:print i
170 // lldbg-check:[...]$8 = Struct { a: 9, b: 10 }
171 // lldbr-check:(destructured_local::Struct) i = Struct { a: 9, b: 10 }
172 // lldb-command:print j
173 // lldbg-check:[...]$9 = 11
174 // lldbr-check:(i16) j = 11
175
176 // lldb-command:print k
177 // lldbg-check:[...]$10 = 12
178 // lldbr-check:(i64) k = 12
179 // lldb-command:print l
180 // lldbg-check:[...]$11 = 13
181 // lldbr-check:(i32) l = 13
182
183 // lldb-command:print m
184 // lldbg-check:[...]$12 = 14
185 // lldbr-check:(i32) m = 14
186 // lldb-command:print n
187 // lldbg-check:[...]$13 = 16
188 // lldbr-check:(i32) n = 16
189
190 // lldb-command:print o
191 // lldbg-check:[...]$14 = 18
192 // lldbr-check:(i32) o = 18
193
194 // lldb-command:print p
195 // lldbg-check:[...]$15 = 19
196 // lldbr-check:(i64) p = 19
197 // lldb-command:print q
198 // lldbg-check:[...]$16 = 20
199 // lldbr-check:(i32) q = 20
200 // lldb-command:print r
201 // lldbg-check:[...]$17 = Struct { a: 21, b: 22 }
202 // lldbr-check:(destructured_local::Struct) r = Struct { a: 21, b: 22 }
203
204 // lldb-command:print s
205 // lldbg-check:[...]$18 = 24
206 // lldbr-check:(i32) s = 24
207 // lldb-command:print t
208 // lldbg-check:[...]$19 = 23
209 // lldbr-check:(i64) t = 23
210
211 // lldb-command:print u
212 // lldbg-check:[...]$20 = 25
213 // lldbr-check:(i32) u = 25
214 // lldb-command:print v
215 // lldbg-check:[...]$21 = 26
216 // lldbr-check:(i32) v = 26
217 // lldb-command:print w
218 // lldbg-check:[...]$22 = 27
219 // lldbr-check:(i32) w = 27
220 // lldb-command:print x
221 // lldbg-check:[...]$23 = 28
222 // lldbr-check:(i32) x = 28
223 // lldb-command:print y
224 // lldbg-check:[...]$24 = 29
225 // lldbr-check:(i64) y = 29
226 // lldb-command:print z
227 // lldbg-check:[...]$25 = 30
228 // lldbr-check:(i32) z = 30
229 // lldb-command:print ae
230 // lldbg-check:[...]$26 = 31
231 // lldbr-check:(i64) ae = 31
232 // lldb-command:print oe
233 // lldbg-check:[...]$27 = 32
234 // lldbr-check:(i32) oe = 32
235 // lldb-command:print ue
236 // lldbg-check:[...]$28 = 33
237 // lldbr-check:(i32) ue = 33
238
239 // lldb-command:print aa
240 // lldbg-check:[...]$29 = (34, 35)
241 // lldbr-check:((i32, i32)) aa = { = 34 = 35 }
242
243 // lldb-command:print bb
244 // lldbg-check:[...]$30 = (36, 37)
245 // lldbr-check:((i32, i32)) bb = { = 36 = 37 }
246
247 // lldb-command:print cc
248 // lldbg-check:[...]$31 = 38
249 // lldbr-check:(i32) cc = 38
250
251 // lldb-command:print dd
252 // lldbg-check:[...]$32 = (40, 41, 42)
253 // lldbr-check:((i32, i32, i32)) dd = { = 40 = 41 = 42 }
254
255 // lldb-command:print *ee
256 // lldbg-check:[...]$33 = (43, 44, 45)
257 // lldbr-check:((i32, i32, i32)) *ee = { = 43 = 44 = 45 }
258
259 // lldb-command:print *ff
260 // lldbg-check:[...]$34 = 46
261 // lldbr-check:(i32) *ff = 46
262
263 // lldb-command:print gg
264 // lldbg-check:[...]$35 = (47, 48)
265 // lldbr-check:((i32, i32)) gg = { = 47 = 48 }
266
267 // lldb-command:print *hh
268 // lldbg-check:[...]$36 = 50
269 // lldbr-check:(i32) *hh = 50
270
271 // lldb-command:print ii
272 // lldbg-check:[...]$37 = 51
273 // lldbr-check:(i32) ii = 51
274
275 // lldb-command:print *jj
276 // lldbg-check:[...]$38 = 52
277 // lldbr-check:(i32) *jj = 52
278
279 // lldb-command:print kk
280 // lldbg-check:[...]$39 = 53
281 // lldbr-check:(f64) kk = 53
282
283 // lldb-command:print ll
284 // lldbg-check:[...]$40 = 54
285 // lldbr-check:(isize) ll = 54
286
287 // lldb-command:print mm
288 // lldbg-check:[...]$41 = 55
289 // lldbr-check:(f64) mm = 55
290
291 // lldb-command:print *nn
292 // lldbg-check:[...]$42 = 56
293 // lldbr-check:(isize) *nn = 56
294
295
296 #![allow(unused_variables)]
297 #![feature(box_patterns)]
298 #![feature(box_syntax)]
299 #![feature(omit_gdb_pretty_printer_section)]
300 #![omit_gdb_pretty_printer_section]
301
302 use self::Univariant::Unit;
303
304 struct Struct {
305     a: i64,
306     b: i32
307 }
308
309 enum Univariant {
310     Unit(i32)
311 }
312
313 struct TupleStruct (f64, isize);
314
315
316 fn main() {
317     // simple tuple
318     let (a, b) : (isize, bool) = (1, false);
319
320     // nested tuple
321     let (c, (d, e)) : (isize, (u16, u16)) = (2, (3, 4));
322
323     // bind tuple-typed value to one name (destructure only first level)
324     let (f, g) : (isize, (u32, u32)) = (5, (6, 7));
325
326     // struct as tuple element
327     let (h, i, j) : (i16, Struct, i16) = (8, Struct { a: 9, b: 10 }, 11);
328
329     // struct pattern
330     let Struct { a: k, b: l } = Struct { a: 12, b: 13 };
331
332     // ignored tuple element
333     let (m, _, n) = (14, 15, 16);
334
335     // ignored struct field
336     let Struct { b: o, .. } = Struct { a: 17, b: 18 };
337
338     // one struct destructured, one not
339     let (Struct { a: p, b: q }, r) = (Struct { a: 19, b: 20 }, Struct { a: 21, b: 22 });
340
341     // different order of struct fields
342     let Struct { b: s, a: t } = Struct { a: 23, b: 24 };
343
344     // complex nesting
345     let ((u, v), ((w, (x, Struct { a: y, b: z})), Struct { a: ae, b: oe }), ue) =
346         ((25, 26), ((27, (28, Struct { a: 29, b: 30})), Struct { a: 31, b: 32 }), 33);
347
348     // reference
349     let &aa = &(34, 35);
350
351     // reference
352     let &bb = &(36, 37);
353
354     // contained reference
355     let (&cc, _) = (&38, 39);
356
357     // unique pointer
358     let box dd = box (40, 41, 42);
359
360     // ref binding
361     let ref ee = (43, 44, 45);
362
363     // ref binding in tuple
364     let (ref ff, gg) = (46, (47, 48));
365
366     // ref binding in struct
367     let Struct { b: ref hh, .. } = Struct { a: 49, b: 50 };
368
369     // univariant enum
370     let Unit(ii) = Unit(51);
371
372     // univariant enum with ref      binding
373     let &Unit(ref jj) = &Unit(52);
374
375     // tuple struct
376     let &TupleStruct(kk, ll) = &TupleStruct(53.0, 54);
377
378     // tuple struct with ref binding
379     let &TupleStruct(mm, ref nn) = &TupleStruct(55.0, 56);
380
381     zzz(); // #break
382 }
383
384 fn zzz() { () }