]> git.lizzy.rs Git - rust.git/blob - src/test/debuginfo/var-captured-in-stack-closure.rs
Auto merge of #54624 - arielb1:evaluate-outlives, r=nikomatsakis
[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 // gdbg-check:$3 = {a = -3, b = 4.5, c = 5}
25 // gdbr-check:$3 = var_captured_in_stack_closure::Struct {a: -3, b: 4.5, c: 5}
26 // gdb-command:print *struct_ref
27 // gdbg-check:$4 = {a = -3, b = 4.5, c = 5}
28 // gdbr-check:$4 = var_captured_in_stack_closure::Struct {a: -3, b: 4.5, c: 5}
29 // gdb-command:print *owned
30 // gdb-check:$5 = 6
31
32 // gdb-command:continue
33
34 // gdb-command:print variable
35 // gdb-check:$6 = 2
36 // gdb-command:print constant
37 // gdb-check:$7 = 2
38 // gdb-command:print a_struct
39 // gdbg-check:$8 = {a = -3, b = 4.5, c = 5}
40 // gdbr-check:$8 = var_captured_in_stack_closure::Struct {a: -3, b: 4.5, c: 5}
41 // gdb-command:print *struct_ref
42 // gdbg-check:$9 = {a = -3, b = 4.5, c = 5}
43 // gdbr-check:$9 = var_captured_in_stack_closure::Struct {a: -3, b: 4.5, c: 5}
44 // gdb-command:print *owned
45 // gdb-check:$10 = 6
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
63 // lldb-command:continue
64
65 // lldb-command:print variable
66 // lldb-check:[...]$5 = 2
67 // lldb-command:print constant
68 // lldb-check:[...]$6 = 2
69 // lldb-command:print a_struct
70 // lldb-check:[...]$7 = Struct { a: -3, b: 4.5, c: 5 }
71 // lldb-command:print *struct_ref
72 // lldb-check:[...]$8 = Struct { a: -3, b: 4.5, c: 5 }
73 // lldb-command:print *owned
74 // lldb-check:[...]$9 = 6
75
76 #![feature(box_syntax)]
77 #![allow(unused_variables)]
78 #![feature(omit_gdb_pretty_printer_section)]
79 #![omit_gdb_pretty_printer_section]
80
81 struct Struct {
82     a: isize,
83     b: f64,
84     c: usize
85 }
86
87 fn main() {
88     let mut variable = 1;
89     let constant = 2;
90
91     let a_struct = Struct {
92         a: -3,
93         b: 4.5,
94         c: 5
95     };
96
97     let struct_ref = &a_struct;
98     let owned: Box<_> = box 6;
99
100     {
101         let mut first_closure = || {
102             zzz(); // #break
103             variable = constant + a_struct.a + struct_ref.a + *owned;
104         };
105
106         first_closure();
107     }
108
109     {
110         let mut second_closure = || {
111             zzz(); // #break
112             variable = constant + a_struct.a + struct_ref.a + *owned;
113         };
114         second_closure();
115     }
116 }
117
118 fn zzz() {()}