]> git.lizzy.rs Git - rust.git/blob - src/test/debuginfo/var-captured-in-sendable-closure.rs
Auto merge of #82552 - GuillaumeGomez:rollup-8dn1ztn, r=GuillaumeGomez
[rust.git] / src / test / debuginfo / var-captured-in-sendable-closure.rs
1 // min-lldb-version: 310
2
3 // compile-flags:-g
4
5 // === GDB TESTS ===================================================================================
6
7 // gdb-command:run
8
9 // gdb-command:print constant
10 // gdb-check:$1 = 1
11 // gdb-command:print a_struct
12 // gdbg-check:$2 = {a = -2, b = 3.5, c = 4}
13 // gdbr-check:$2 = var_captured_in_sendable_closure::Struct {a: -2, b: 3.5, c: 4}
14 // gdb-command:print *owned
15 // gdb-check:$3 = 5
16 // gdb-command:continue
17
18 // gdb-command:print constant2
19 // gdb-check:$4 = 6
20 // gdb-command:continue
21
22 // === LLDB TESTS ==================================================================================
23
24 // lldb-command:run
25
26 // lldb-command:print constant
27 // lldbg-check:[...]$0 = 1
28 // lldbr-check:(isize) constant = 1
29 // lldb-command:print a_struct
30 // lldbg-check:[...]$1 = { a = -2 b = 3.5 c = 4 }
31 // lldbr-check:(var_captured_in_sendable_closure::Struct) a_struct = { a = -2 b = 3.5 c = 4 }
32 // lldb-command:print *owned
33 // lldbg-check:[...]$2 = 5
34 // lldbr-check:(isize) *owned = 5
35
36 #![allow(unused_variables)]
37 #![feature(box_syntax)]
38 #![feature(omit_gdb_pretty_printer_section)]
39 #![omit_gdb_pretty_printer_section]
40
41 struct Struct {
42     a: isize,
43     b: f64,
44     c: usize
45 }
46
47 fn main() {
48     let constant = 1;
49
50     let a_struct = Struct {
51         a: -2,
52         b: 3.5,
53         c: 4
54     };
55
56     let owned: Box<_> = box 5;
57
58     let closure = move || {
59         zzz(); // #break
60         do_something(&constant, &a_struct.a, &*owned);
61     };
62
63     closure();
64
65     let constant2 = 6_usize;
66
67     // The `self` argument of the following closure should be passed by value
68     // to FnOnce::call_once(self, args), which gets codegened a bit differently
69     // than the regular case. Let's make sure this is supported too.
70     let immedate_env = move || {
71         zzz(); // #break
72         return constant2;
73     };
74
75     immedate_env();
76 }
77
78 fn do_something(_: &isize, _:&isize, _:&isize) {
79
80 }
81
82 fn zzz() {()}