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