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