]> git.lizzy.rs Git - rust.git/blob - tests/debuginfo/var-captured-in-sendable-closure.rs
Merge commit '7d53619064ab7045c383644cb445052d2a3d46db' into sync_cg_clif-2023-02-09
[rust.git] / tests / 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(omit_gdb_pretty_printer_section)]
38 #![omit_gdb_pretty_printer_section]
39
40 struct Struct {
41     a: isize,
42     b: f64,
43     c: usize
44 }
45
46 fn main() {
47     let constant = 1;
48
49     let a_struct = Struct {
50         a: -2,
51         b: 3.5,
52         c: 4
53     };
54
55     let owned: Box<_> = Box::new(5);
56
57     let closure = move || {
58         zzz(); // #break
59         do_something(&constant, &a_struct.a, &*owned);
60     };
61
62     closure();
63
64     let constant2 = 6_usize;
65
66     // The `self` argument of the following closure should be passed by value
67     // to FnOnce::call_once(self, args), which gets codegened a bit differently
68     // than the regular case. Let's make sure this is supported too.
69     let immedate_env = move || {
70         zzz(); // #break
71         return constant2;
72     };
73
74     immedate_env();
75 }
76
77 fn do_something(_: &isize, _:&isize, _:&isize) {
78
79 }
80
81 fn zzz() {()}