]> git.lizzy.rs Git - rust.git/blob - src/test/debuginfo/destructured-for-loop-variable.rs
Auto merge of #28816 - petrochenkov:unistruct, r=nrc
[rust.git] / src / test / debuginfo / destructured-for-loop-variable.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 // DESTRUCTURED STRUCT
20 // gdb-command:print x
21 // gdb-check:$1 = 400
22 // gdb-command:print y
23 // gdb-check:$2 = 401.5
24 // gdb-command:print z
25 // gdb-check:$3 = true
26 // gdb-command:continue
27
28 // DESTRUCTURED TUPLE
29 // gdb-command:print/x _i8
30 // gdb-check:$4 = 0x6f
31 // gdb-command:print/x _u8
32 // gdb-check:$5 = 0x70
33 // gdb-command:print _i16
34 // gdb-check:$6 = -113
35 // gdb-command:print _u16
36 // gdb-check:$7 = 114
37 // gdb-command:print _i32
38 // gdb-check:$8 = -115
39 // gdb-command:print _u32
40 // gdb-check:$9 = 116
41 // gdb-command:print _i64
42 // gdb-check:$10 = -117
43 // gdb-command:print _u64
44 // gdb-check:$11 = 118
45 // gdb-command:print _f32
46 // gdb-check:$12 = 119.5
47 // gdb-command:print _f64
48 // gdb-check:$13 = 120.5
49 // gdb-command:continue
50
51 // MORE COMPLEX CASE
52 // gdb-command:print v1
53 // gdb-check:$14 = 80000
54 // gdb-command:print x1
55 // gdb-check:$15 = 8000
56 // gdb-command:print *y1
57 // gdb-check:$16 = 80001.5
58 // gdb-command:print z1
59 // gdb-check:$17 = false
60 // gdb-command:print *x2
61 // gdb-check:$18 = -30000
62 // gdb-command:print y2
63 // gdb-check:$19 = -300001.5
64 // gdb-command:print *z2
65 // gdb-check:$20 = true
66 // gdb-command:print v2
67 // gdb-check:$21 = 854237.5
68 // gdb-command:continue
69
70 // SIMPLE IDENTIFIER
71 // gdb-command:print i
72 // gdb-check:$22 = 1234
73 // gdb-command:continue
74
75 // gdb-command:print simple_struct_ident
76 // gdb-check:$23 = {x = 3537, y = 35437.5, z = true}
77 // gdb-command:continue
78
79 // gdb-command:print simple_tuple_ident
80 // gdb-check:$24 = {__0 = 34903493, __1 = 232323}
81 // gdb-command:continue
82
83 // === LLDB TESTS ==================================================================================
84
85 // lldb-command:type format add --format hex char
86 // lldb-command:type format add --format hex 'unsigned char'
87
88 // lldb-command:run
89
90 // DESTRUCTURED STRUCT
91 // lldb-command:print x
92 // lldb-check:[...]$0 = 400
93 // lldb-command:print y
94 // lldb-check:[...]$1 = 401.5
95 // lldb-command:print z
96 // lldb-check:[...]$2 = true
97 // lldb-command:continue
98
99 // DESTRUCTURED TUPLE
100 // lldb-command:print _i8
101 // lldb-check:[...]$3 = 0x6f
102 // lldb-command:print _u8
103 // lldb-check:[...]$4 = 0x70
104 // lldb-command:print _i16
105 // lldb-check:[...]$5 = -113
106 // lldb-command:print _u16
107 // lldb-check:[...]$6 = 114
108 // lldb-command:print _i32
109 // lldb-check:[...]$7 = -115
110 // lldb-command:print _u32
111 // lldb-check:[...]$8 = 116
112 // lldb-command:print _i64
113 // lldb-check:[...]$9 = -117
114 // lldb-command:print _u64
115 // lldb-check:[...]$10 = 118
116 // lldb-command:print _f32
117 // lldb-check:[...]$11 = 119.5
118 // lldb-command:print _f64
119 // lldb-check:[...]$12 = 120.5
120 // lldb-command:continue
121
122 // MORE COMPLEX CASE
123 // lldb-command:print v1
124 // lldb-check:[...]$13 = 80000
125 // lldb-command:print x1
126 // lldb-check:[...]$14 = 8000
127 // lldb-command:print *y1
128 // lldb-check:[...]$15 = 80001.5
129 // lldb-command:print z1
130 // lldb-check:[...]$16 = false
131 // lldb-command:print *x2
132 // lldb-check:[...]$17 = -30000
133 // lldb-command:print y2
134 // lldb-check:[...]$18 = -300001.5
135 // lldb-command:print *z2
136 // lldb-check:[...]$19 = true
137 // lldb-command:print v2
138 // lldb-check:[...]$20 = 854237.5
139 // lldb-command:continue
140
141 // SIMPLE IDENTIFIER
142 // lldb-command:print i
143 // lldb-check:[...]$21 = 1234
144 // lldb-command:continue
145
146 // lldb-command:print simple_struct_ident
147 // lldb-check:[...]$22 = Struct { x: 3537, y: 35437.5, z: true }
148 // lldb-command:continue
149
150 // lldb-command:print simple_tuple_ident
151 // lldb-check:[...]$23 = (34903493, 232323)
152 // lldb-command:continue
153
154 #![allow(unused_variables)]
155 #![feature(box_patterns)]
156 #![feature(box_syntax)]
157 #![feature(omit_gdb_pretty_printer_section)]
158 #![omit_gdb_pretty_printer_section]
159
160 struct Struct {
161     x: i16,
162     y: f32,
163     z: bool
164 }
165
166 fn main() {
167
168     let s = Struct {
169         x: 400,
170         y: 401.5,
171         z: true
172     };
173
174     for &Struct { x, y, z } in &[s] {
175         zzz(); // #break
176     }
177
178     let tuple: (i8, u8, i16, u16, i32, u32, i64, u64, f32, f64) =
179         (0x6f, 0x70, -113, 114, -115, 116, -117, 118, 119.5, 120.5);
180
181     for &(_i8, _u8, _i16, _u16, _i32, _u32, _i64, _u64, _f32, _f64) in &[tuple] {
182         zzz(); // #break
183     }
184
185     let more_complex: (i32, &Struct, Struct, Box<f64>) =
186         (80000,
187          &Struct {
188             x: 8000,
189             y: 80001.5,
190             z: false
191          },
192          Struct {
193             x: -30000,
194             y: -300001.5,
195             z: true
196          },
197          box 854237.5);
198
199     for &(v1,
200           &Struct { x: x1, y: ref y1, z: z1 },
201           Struct { x: ref x2, y: y2, z: ref z2 },
202           box v2) in [more_complex].iter() {
203         zzz(); // #break
204     }
205
206     for i in 1234..1235 {
207         zzz(); // #break
208     }
209
210     for simple_struct_ident in
211       vec![Struct {
212             x: 3537,
213             y: 35437.5,
214             z: true
215            }].into_iter() {
216       zzz(); // #break
217     }
218
219     for simple_tuple_ident in vec![(34903493u32, 232323i64)] {
220       zzz(); // #break
221     }
222 }
223
224 fn zzz() {()}