]> git.lizzy.rs Git - rust.git/blob - src/test/debuginfo/var-captured-in-stack-closure.rs
Auto merge of #28816 - petrochenkov:unistruct, r=nrc
[rust.git] / src / test / debuginfo / var-captured-in-stack-closure.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 variable
20 // gdb-check:$1 = 1
21 // gdb-command:print constant
22 // gdb-check:$2 = 2
23 // gdb-command:print a_struct
24 // gdb-check:$3 = {a = -3, b = 4.5, c = 5}
25 // gdb-command:print *struct_ref
26 // gdb-check:$4 = {a = -3, b = 4.5, c = 5}
27 // gdb-command:print *owned
28 // gdb-check:$5 = 6
29
30 // gdb-command:continue
31
32 // gdb-command:print variable
33 // gdb-check:$6 = 2
34 // gdb-command:print constant
35 // gdb-check:$7 = 2
36 // gdb-command:print a_struct
37 // gdb-check:$8 = {a = -3, b = 4.5, c = 5}
38 // gdb-command:print *struct_ref
39 // gdb-check:$9 = {a = -3, b = 4.5, c = 5}
40 // gdb-command:print *owned
41 // gdb-check:$10 = 6
42
43
44 // === LLDB TESTS ==================================================================================
45
46 // lldb-command:run
47
48 // lldb-command:print variable
49 // lldb-check:[...]$0 = 1
50 // lldb-command:print constant
51 // lldb-check:[...]$1 = 2
52 // lldb-command:print a_struct
53 // lldb-check:[...]$2 = Struct { a: -3, b: 4.5, c: 5 }
54 // lldb-command:print *struct_ref
55 // lldb-check:[...]$3 = Struct { a: -3, b: 4.5, c: 5 }
56 // lldb-command:print *owned
57 // lldb-check:[...]$4 = 6
58
59 // lldb-command:continue
60
61 // lldb-command:print variable
62 // lldb-check:[...]$5 = 2
63 // lldb-command:print constant
64 // lldb-check:[...]$6 = 2
65 // lldb-command:print a_struct
66 // lldb-check:[...]$7 = Struct { a: -3, b: 4.5, c: 5 }
67 // lldb-command:print *struct_ref
68 // lldb-check:[...]$8 = Struct { a: -3, b: 4.5, c: 5 }
69 // lldb-command:print *owned
70 // lldb-check:[...]$9 = 6
71
72 #![feature(unboxed_closures, box_syntax)]
73 #![allow(unused_variables)]
74 #![feature(omit_gdb_pretty_printer_section)]
75 #![omit_gdb_pretty_printer_section]
76
77 struct Struct {
78     a: isize,
79     b: f64,
80     c: usize
81 }
82
83 fn main() {
84     let mut variable = 1;
85     let constant = 2;
86
87     let a_struct = Struct {
88         a: -3,
89         b: 4.5,
90         c: 5
91     };
92
93     let struct_ref = &a_struct;
94     let owned: Box<_> = box 6;
95
96     {
97         let mut first_closure = || {
98             zzz(); // #break
99             variable = constant + a_struct.a + struct_ref.a + *owned;
100         };
101
102         first_closure();
103     }
104
105     {
106         let mut second_closure = || {
107             zzz(); // #break
108             variable = constant + a_struct.a + struct_ref.a + *owned;
109         };
110         second_closure();
111     }
112 }
113
114 fn zzz() {()}