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