]> git.lizzy.rs Git - rust.git/blob - src/test/debuginfo/destructured-local.rs
Rollup merge of #37836 - steveklabnik:remove-incorrect-reference-comment, r=Guillaume...
[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 // lldb-check:[...]$0 = 1
144 // lldb-command:print b
145 // lldb-check:[...]$1 = false
146
147 // lldb-command:print c
148 // lldb-check:[...]$2 = 2
149 // lldb-command:print d
150 // lldb-check:[...]$3 = 3
151 // lldb-command:print e
152 // lldb-check:[...]$4 = 4
153
154 // lldb-command:print f
155 // lldb-check:[...]$5 = 5
156 // lldb-command:print g
157 // lldb-check:[...]$6 = (6, 7)
158
159 // lldb-command:print h
160 // lldb-check:[...]$7 = 8
161 // lldb-command:print i
162 // lldb-check:[...]$8 = Struct { a: 9, b: 10 }
163 // lldb-command:print j
164 // lldb-check:[...]$9 = 11
165
166 // lldb-command:print k
167 // lldb-check:[...]$10 = 12
168 // lldb-command:print l
169 // lldb-check:[...]$11 = 13
170
171 // lldb-command:print m
172 // lldb-check:[...]$12 = 14
173 // lldb-command:print n
174 // lldb-check:[...]$13 = 16
175
176 // lldb-command:print o
177 // lldb-check:[...]$14 = 18
178
179 // lldb-command:print p
180 // lldb-check:[...]$15 = 19
181 // lldb-command:print q
182 // lldb-check:[...]$16 = 20
183 // lldb-command:print r
184 // lldb-check:[...]$17 = Struct { a: 21, b: 22 }
185
186 // lldb-command:print s
187 // lldb-check:[...]$18 = 24
188 // lldb-command:print t
189 // lldb-check:[...]$19 = 23
190
191 // lldb-command:print u
192 // lldb-check:[...]$20 = 25
193 // lldb-command:print v
194 // lldb-check:[...]$21 = 26
195 // lldb-command:print w
196 // lldb-check:[...]$22 = 27
197 // lldb-command:print x
198 // lldb-check:[...]$23 = 28
199 // lldb-command:print y
200 // lldb-check:[...]$24 = 29
201 // lldb-command:print z
202 // lldb-check:[...]$25 = 30
203 // lldb-command:print ae
204 // lldb-check:[...]$26 = 31
205 // lldb-command:print oe
206 // lldb-check:[...]$27 = 32
207 // lldb-command:print ue
208 // lldb-check:[...]$28 = 33
209
210 // lldb-command:print aa
211 // lldb-check:[...]$29 = (34, 35)
212
213 // lldb-command:print bb
214 // lldb-check:[...]$30 = (36, 37)
215
216 // lldb-command:print cc
217 // lldb-check:[...]$31 = 38
218
219 // lldb-command:print dd
220 // lldb-check:[...]$32 = (40, 41, 42)
221
222 // lldb-command:print *ee
223 // lldb-check:[...]$33 = (43, 44, 45)
224
225 // lldb-command:print *ff
226 // lldb-check:[...]$34 = 46
227
228 // lldb-command:print gg
229 // lldb-check:[...]$35 = (47, 48)
230
231 // lldb-command:print *hh
232 // lldb-check:[...]$36 = 50
233
234 // lldb-command:print ii
235 // lldb-check:[...]$37 = 51
236
237 // lldb-command:print *jj
238 // lldb-check:[...]$38 = 52
239
240 // lldb-command:print kk
241 // lldb-check:[...]$39 = 53
242
243 // lldb-command:print ll
244 // lldb-check:[...]$40 = 54
245
246 // lldb-command:print mm
247 // lldb-check:[...]$41 = 55
248
249 // lldb-command:print *nn
250 // lldb-check:[...]$42 = 56
251
252
253 #![allow(unused_variables)]
254 #![feature(box_patterns)]
255 #![feature(box_syntax)]
256 #![feature(omit_gdb_pretty_printer_section)]
257 #![omit_gdb_pretty_printer_section]
258
259 use self::Univariant::Unit;
260
261 struct Struct {
262     a: i64,
263     b: i32
264 }
265
266 enum Univariant {
267     Unit(i32)
268 }
269
270 struct TupleStruct (f64, isize);
271
272
273 fn main() {
274     // simple tuple
275     let (a, b) : (isize, bool) = (1, false);
276
277     // nested tuple
278     let (c, (d, e)) : (isize, (u16, u16)) = (2, (3, 4));
279
280     // bind tuple-typed value to one name (destructure only first level)
281     let (f, g) : (isize, (u32, u32)) = (5, (6, 7));
282
283     // struct as tuple element
284     let (h, i, j) : (i16, Struct, i16) = (8, Struct { a: 9, b: 10 }, 11);
285
286     // struct pattern
287     let Struct { a: k, b: l } = Struct { a: 12, b: 13 };
288
289     // ignored tuple element
290     let (m, _, n) = (14, 15, 16);
291
292     // ignored struct field
293     let Struct { b: o, .. } = Struct { a: 17, b: 18 };
294
295     // one struct destructured, one not
296     let (Struct { a: p, b: q }, r) = (Struct { a: 19, b: 20 }, Struct { a: 21, b: 22 });
297
298     // different order of struct fields
299     let Struct { b: s, a: t } = Struct { a: 23, b: 24 };
300
301     // complex nesting
302     let ((u, v), ((w, (x, Struct { a: y, b: z})), Struct { a: ae, b: oe }), ue) =
303         ((25, 26), ((27, (28, Struct { a: 29, b: 30})), Struct { a: 31, b: 32 }), 33);
304
305     // reference
306     let &aa = &(34, 35);
307
308     // reference
309     let &bb = &(36, 37);
310
311     // contained reference
312     let (&cc, _) = (&38, 39);
313
314     // unique pointer
315     let box dd = box (40, 41, 42);
316
317     // ref binding
318     let ref ee = (43, 44, 45);
319
320     // ref binding in tuple
321     let (ref ff, gg) = (46, (47, 48));
322
323     // ref binding in struct
324     let Struct { b: ref hh, .. } = Struct { a: 49, b: 50 };
325
326     // univariant enum
327     let Unit(ii) = Unit(51);
328
329     // univariant enum with ref      binding
330     let &Unit(ref jj) = &Unit(52);
331
332     // tuple struct
333     let &TupleStruct(kk, ll) = &TupleStruct(53.0, 54);
334
335     // tuple struct with ref binding
336     let &TupleStruct(mm, ref nn) = &TupleStruct(55.0, 56);
337
338     zzz(); // #break
339 }
340
341 fn zzz() { () }