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