]> git.lizzy.rs Git - rust.git/blob - src/test/debuginfo/destructured-fn-argument.rs
Auto merge of #54720 - davidtwco:issue-51191, r=nikomatsakis
[rust.git] / src / test / debuginfo / destructured-fn-argument.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 // gdb-command:continue
24
25 // gdb-command:print a
26 // gdb-check:$3 = 2
27 // gdb-command:print b
28 // gdb-check:$4 = 3
29 // gdb-command:print c
30 // gdb-check:$5 = 4
31 // gdb-command:continue
32
33 // gdb-command:print a
34 // gdb-check:$6 = 5
35 // gdb-command:print b
36 // gdbg-check:$7 = {__0 = 6, __1 = 7}
37 // gdbr-check:$7 = (6, 7)
38 // gdb-command:continue
39
40 // gdb-command:print h
41 // gdb-check:$8 = 8
42 // gdb-command:print i
43 // gdbg-check:$9 = {a = 9, b = 10}
44 // gdbr-check:$9 = destructured_fn_argument::Struct {a: 9, b: 10}
45 // gdb-command:print j
46 // gdb-check:$10 = 11
47 // gdb-command:continue
48
49 // gdb-command:print k
50 // gdb-check:$11 = 12
51 // gdb-command:print l
52 // gdb-check:$12 = 13
53 // gdb-command:continue
54
55 // gdb-command:print m
56 // gdb-check:$13 = 14
57 // gdb-command:print n
58 // gdb-check:$14 = 16
59 // gdb-command:continue
60
61 // gdb-command:print o
62 // gdb-check:$15 = 18
63 // gdb-command:continue
64
65 // gdb-command:print p
66 // gdb-check:$16 = 19
67 // gdb-command:print q
68 // gdb-check:$17 = 20
69 // gdb-command:print r
70 // gdbg-check:$18 = {a = 21, b = 22}
71 // gdbr-check:$18 = destructured_fn_argument::Struct {a: 21, b: 22}
72 // gdb-command:continue
73
74 // gdb-command:print s
75 // gdb-check:$19 = 24
76 // gdb-command:print t
77 // gdb-check:$20 = 23
78 // gdb-command:continue
79
80 // gdb-command:print u
81 // gdb-check:$21 = 25
82 // gdb-command:print v
83 // gdb-check:$22 = 26
84 // gdb-command:print w
85 // gdb-check:$23 = 27
86 // gdb-command:print x
87 // gdb-check:$24 = 28
88 // gdb-command:print y
89 // gdb-check:$25 = 29
90 // gdb-command:print z
91 // gdb-check:$26 = 30
92 // gdb-command:print ae
93 // gdb-check:$27 = 31
94 // gdb-command:print oe
95 // gdb-check:$28 = 32
96 // gdb-command:print ue
97 // gdb-check:$29 = 33
98 // gdb-command:continue
99
100 // gdb-command:print aa
101 // gdbg-check:$30 = {__0 = 34, __1 = 35}
102 // gdbr-check:$30 = (34, 35)
103 // gdb-command:continue
104
105 // gdb-command:print bb
106 // gdbg-check:$31 = {__0 = 36, __1 = 37}
107 // gdbr-check:$31 = (36, 37)
108 // gdb-command:continue
109
110 // gdb-command:print cc
111 // gdb-check:$32 = 38
112 // gdb-command:continue
113
114 // gdb-command:print dd
115 // gdbg-check:$33 = {__0 = 40, __1 = 41, __2 = 42}
116 // gdbr-check:$33 = (40, 41, 42)
117 // gdb-command:continue
118
119 // gdb-command:print *ee
120 // gdbg-check:$34 = {__0 = 43, __1 = 44, __2 = 45}
121 // gdbr-check:$34 = (43, 44, 45)
122 // gdb-command:continue
123
124 // gdb-command:print *ff
125 // gdb-check:$35 = 46
126 // gdb-command:print gg
127 // gdbg-check:$36 = {__0 = 47, __1 = 48}
128 // gdbr-check:$36 = (47, 48)
129 // gdb-command:continue
130
131 // gdb-command:print *hh
132 // gdb-check:$37 = 50
133 // gdb-command:continue
134
135 // gdb-command:print ii
136 // gdb-check:$38 = 51
137 // gdb-command:continue
138
139 // gdb-command:print *jj
140 // gdb-check:$39 = 52
141 // gdb-command:continue
142
143 // gdb-command:print kk
144 // gdb-check:$40 = 53
145 // gdb-command:print ll
146 // gdb-check:$41 = 54
147 // gdb-command:continue
148
149 // gdb-command:print mm
150 // gdb-check:$42 = 55
151 // gdb-command:print *nn
152 // gdb-check:$43 = 56
153 // gdb-command:continue
154
155 // gdb-command:print oo
156 // gdb-check:$44 = 57
157 // gdb-command:print pp
158 // gdb-check:$45 = 58
159 // gdb-command:print qq
160 // gdb-check:$46 = 59
161 // gdb-command:continue
162
163 // gdb-command:print rr
164 // gdb-check:$47 = 60
165 // gdb-command:print ss
166 // gdb-check:$48 = 61
167 // gdb-command:print tt
168 // gdb-check:$49 = 62
169 // gdb-command:continue
170
171
172 // === LLDB TESTS ==================================================================================
173
174 // lldb-command:run
175
176 // lldb-command:print a
177 // lldb-check:[...]$0 = 1
178 // lldb-command:print b
179 // lldb-check:[...]$1 = false
180 // lldb-command:continue
181
182 // lldb-command:print a
183 // lldb-check:[...]$2 = 2
184 // lldb-command:print b
185 // lldb-check:[...]$3 = 3
186 // lldb-command:print c
187 // lldb-check:[...]$4 = 4
188 // lldb-command:continue
189
190 // lldb-command:print a
191 // lldb-check:[...]$5 = 5
192 // lldb-command:print b
193 // lldb-check:[...]$6 = (6, 7)
194 // lldb-command:continue
195
196 // lldb-command:print h
197 // lldb-check:[...]$7 = 8
198 // lldb-command:print i
199 // lldb-check:[...]$8 = Struct { a: 9, b: 10 }
200 // lldb-command:print j
201 // lldb-check:[...]$9 = 11
202 // lldb-command:continue
203
204 // lldb-command:print k
205 // lldb-check:[...]$10 = 12
206 // lldb-command:print l
207 // lldb-check:[...]$11 = 13
208 // lldb-command:continue
209
210 // lldb-command:print m
211 // lldb-check:[...]$12 = 14
212 // lldb-command:print n
213 // lldb-check:[...]$13 = 16
214 // lldb-command:continue
215
216 // lldb-command:print o
217 // lldb-check:[...]$14 = 18
218 // lldb-command:continue
219
220 // lldb-command:print p
221 // lldb-check:[...]$15 = 19
222 // lldb-command:print q
223 // lldb-check:[...]$16 = 20
224 // lldb-command:print r
225 // lldb-check:[...]$17 = Struct { a: 21, b: 22 }
226 // lldb-command:continue
227
228 // lldb-command:print s
229 // lldb-check:[...]$18 = 24
230 // lldb-command:print t
231 // lldb-check:[...]$19 = 23
232 // lldb-command:continue
233
234 // lldb-command:print u
235 // lldb-check:[...]$20 = 25
236 // lldb-command:print v
237 // lldb-check:[...]$21 = 26
238 // lldb-command:print w
239 // lldb-check:[...]$22 = 27
240 // lldb-command:print x
241 // lldb-check:[...]$23 = 28
242 // lldb-command:print y
243 // lldb-check:[...]$24 = 29
244 // lldb-command:print z
245 // lldb-check:[...]$25 = 30
246 // lldb-command:print ae
247 // lldb-check:[...]$26 = 31
248 // lldb-command:print oe
249 // lldb-check:[...]$27 = 32
250 // lldb-command:print ue
251 // lldb-check:[...]$28 = 33
252 // lldb-command:continue
253
254 // lldb-command:print aa
255 // lldb-check:[...]$29 = (34, 35)
256 // lldb-command:continue
257
258 // lldb-command:print bb
259 // lldb-check:[...]$30 = (36, 37)
260 // lldb-command:continue
261
262 // lldb-command:print cc
263 // lldb-check:[...]$31 = 38
264 // lldb-command:continue
265
266 // lldb-command:print dd
267 // lldb-check:[...]$32 = (40, 41, 42)
268 // lldb-command:continue
269
270 // lldb-command:print *ee
271 // lldb-check:[...]$33 = (43, 44, 45)
272 // lldb-command:continue
273
274 // lldb-command:print *ff
275 // lldb-check:[...]$34 = 46
276 // lldb-command:print gg
277 // lldb-check:[...]$35 = (47, 48)
278 // lldb-command:continue
279
280 // lldb-command:print *hh
281 // lldb-check:[...]$36 = 50
282 // lldb-command:continue
283
284 // lldb-command:print ii
285 // lldb-check:[...]$37 = 51
286 // lldb-command:continue
287
288 // lldb-command:print *jj
289 // lldb-check:[...]$38 = 52
290 // lldb-command:continue
291
292 // lldb-command:print kk
293 // lldb-check:[...]$39 = 53
294 // lldb-command:print ll
295 // lldb-check:[...]$40 = 54
296 // lldb-command:continue
297
298 // lldb-command:print mm
299 // lldb-check:[...]$41 = 55
300 // lldb-command:print *nn
301 // lldb-check:[...]$42 = 56
302 // lldb-command:continue
303
304 // lldb-command:print oo
305 // lldb-check:[...]$43 = 57
306 // lldb-command:print pp
307 // lldb-check:[...]$44 = 58
308 // lldb-command:print qq
309 // lldb-check:[...]$45 = 59
310 // lldb-command:continue
311
312 // lldb-command:print rr
313 // lldb-check:[...]$46 = 60
314 // lldb-command:print ss
315 // lldb-check:[...]$47 = 61
316 // lldb-command:print tt
317 // lldb-check:[...]$48 = 62
318 // lldb-command:continue
319
320 #![allow(unused_variables)]
321 #![feature(box_patterns)]
322 #![feature(box_syntax)]
323 #![feature(omit_gdb_pretty_printer_section)]
324 #![omit_gdb_pretty_printer_section]
325
326 use self::Univariant::Unit;
327
328 struct Struct {
329     a: i64,
330     b: i32
331 }
332
333 enum Univariant {
334     Unit(i32)
335 }
336
337 struct TupleStruct (f64, isize);
338
339
340 fn simple_tuple((a, b): (isize, bool)) {
341     zzz(); // #break
342 }
343
344 fn nested_tuple((a, (b, c)): (isize, (u16, u16))) {
345     zzz(); // #break
346 }
347
348 fn destructure_only_first_level((a, b): (isize, (u32, u32))) {
349     zzz(); // #break
350 }
351
352 fn struct_as_tuple_element((h, i, j): (i16, Struct, i16)) {
353     zzz(); // #break
354 }
355
356 fn struct_pattern(Struct { a: k, b: l }: Struct) {
357     zzz(); // #break
358 }
359
360 fn ignored_tuple_element((m, _, n): (isize, u16, i32)) {
361     zzz(); // #break
362 }
363
364 fn ignored_struct_field(Struct { b: o, .. }: Struct) {
365     zzz(); // #break
366 }
367
368 fn one_struct_destructured_one_not((Struct { a: p, b: q }, r): (Struct, Struct)) {
369     zzz(); // #break
370 }
371
372 fn different_order_of_struct_fields(Struct { b: s, a: t }: Struct ) {
373     zzz(); // #break
374 }
375
376 fn complex_nesting(((u,   v  ), ((w,   (x,   Struct { a: y, b: z})), Struct { a: ae, b: oe }), ue ):
377                    ((i16, i32), ((i64, (i32, Struct,             )), Struct                 ), u16))
378 {
379     zzz(); // #break
380 }
381
382 fn managed_box(&aa: &(isize, isize)) {
383     zzz(); // #break
384 }
385
386 fn borrowed_pointer(&bb: &(isize, isize)) {
387     zzz(); // #break
388 }
389
390 fn contained_borrowed_pointer((&cc, _): (&isize, isize)) {
391     zzz(); // #break
392 }
393
394 fn unique_pointer(box dd: Box<(isize, isize, isize)>) {
395     zzz(); // #break
396 }
397
398 fn ref_binding(ref ee: (isize, isize, isize)) {
399     zzz(); // #break
400 }
401
402 fn ref_binding_in_tuple((ref ff, gg): (isize, (isize, isize))) {
403     zzz(); // #break
404 }
405
406 fn ref_binding_in_struct(Struct { b: ref hh, .. }: Struct) {
407     zzz(); // #break
408 }
409
410 fn univariant_enum(Unit(ii): Univariant) {
411     zzz(); // #break
412 }
413
414 fn univariant_enum_with_ref_binding(Unit(ref jj): Univariant) {
415     zzz(); // #break
416 }
417
418 fn tuple_struct(TupleStruct(kk, ll): TupleStruct) {
419     zzz(); // #break
420 }
421
422 fn tuple_struct_with_ref_binding(TupleStruct(mm, ref nn): TupleStruct) {
423     zzz(); // #break
424 }
425
426 fn multiple_arguments((oo, pp): (isize, isize), qq : isize) {
427     zzz(); // #break
428 }
429
430 fn main() {
431     simple_tuple((1, false));
432     nested_tuple((2, (3, 4)));
433     destructure_only_first_level((5, (6, 7)));
434     struct_as_tuple_element((8, Struct { a: 9, b: 10 }, 11));
435     struct_pattern(Struct { a: 12, b: 13 });
436     ignored_tuple_element((14, 15, 16));
437     ignored_struct_field(Struct { a: 17, b: 18 });
438     one_struct_destructured_one_not((Struct { a: 19, b: 20 }, Struct { a: 21, b: 22 }));
439     different_order_of_struct_fields(Struct { a: 23, b: 24 });
440     complex_nesting(((25, 26), ((27, (28, Struct { a: 29, b: 30})), Struct { a: 31, b: 32 }), 33));
441     managed_box(&(34, 35));
442     borrowed_pointer(&(36, 37));
443     contained_borrowed_pointer((&38, 39));
444     unique_pointer(box (40, 41, 42));
445     ref_binding((43, 44, 45));
446     ref_binding_in_tuple((46, (47, 48)));
447     ref_binding_in_struct(Struct { a: 49, b: 50 });
448     univariant_enum(Unit(51));
449     univariant_enum_with_ref_binding(Unit(52));
450     tuple_struct(TupleStruct(53.0, 54));
451     tuple_struct_with_ref_binding(TupleStruct(55.0, 56));
452     multiple_arguments((57, 58), 59);
453
454     fn nested_function(rr: isize, (ss, tt): (isize, isize)) {
455         zzz(); // #break
456     }
457
458     nested_function(60, (61, 62));
459 }
460
461 fn zzz() { () }