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