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