]> git.lizzy.rs Git - rust.git/blob - src/test/debuginfo/borrowed-struct.rs
Rollup merge of #53545 - FelixMcFelix:fix-50865-beta, r=petrochenkov
[rust.git] / src / test / debuginfo / borrowed-struct.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 // compile-flags:-g
12 // min-lldb-version: 310
13
14 // === GDB TESTS ===================================================================================
15
16 // gdb-command:run
17
18 // gdb-command:print *stack_val_ref
19 // gdbg-check:$1 = {x = 10, y = 23.5}
20 // gdbr-check:$1 = borrowed_struct::SomeStruct {x: 10, y: 23.5}
21
22 // gdb-command:print *stack_val_interior_ref_1
23 // gdb-check:$2 = 10
24
25 // gdb-command:print *stack_val_interior_ref_2
26 // gdb-check:$3 = 23.5
27
28 // gdb-command:print *ref_to_unnamed
29 // gdbg-check:$4 = {x = 11, y = 24.5}
30 // gdbr-check:$4 = borrowed_struct::SomeStruct {x: 11, y: 24.5}
31
32 // gdb-command:print *unique_val_ref
33 // gdbg-check:$5 = {x = 13, y = 26.5}
34 // gdbr-check:$5 = borrowed_struct::SomeStruct {x: 13, y: 26.5}
35
36 // gdb-command:print *unique_val_interior_ref_1
37 // gdb-check:$6 = 13
38
39 // gdb-command:print *unique_val_interior_ref_2
40 // gdb-check:$7 = 26.5
41
42
43 // === LLDB TESTS ==================================================================================
44
45 // lldb-command:run
46
47 // lldb-command:print *stack_val_ref
48 // lldb-check:[...]$0 = SomeStruct { x: 10, y: 23.5 }
49
50 // lldb-command:print *stack_val_interior_ref_1
51 // lldb-check:[...]$1 = 10
52
53 // lldb-command:print *stack_val_interior_ref_2
54 // lldb-check:[...]$2 = 23.5
55
56 // lldb-command:print *ref_to_unnamed
57 // lldb-check:[...]$3 = SomeStruct { x: 11, y: 24.5 }
58
59 // lldb-command:print *unique_val_ref
60 // lldb-check:[...]$4 = SomeStruct { x: 13, y: 26.5 }
61
62 // lldb-command:print *unique_val_interior_ref_1
63 // lldb-check:[...]$5 = 13
64
65 // lldb-command:print *unique_val_interior_ref_2
66 // lldb-check:[...]$6 = 26.5
67
68 #![allow(unused_variables)]
69 #![feature(box_syntax)]
70 #![feature(omit_gdb_pretty_printer_section)]
71 #![omit_gdb_pretty_printer_section]
72
73 struct SomeStruct {
74     x: isize,
75     y: f64
76 }
77
78 fn main() {
79     let stack_val: SomeStruct = SomeStruct { x: 10, y: 23.5 };
80     let stack_val_ref: &SomeStruct = &stack_val;
81     let stack_val_interior_ref_1: &isize = &stack_val.x;
82     let stack_val_interior_ref_2: &f64 = &stack_val.y;
83     let ref_to_unnamed: &SomeStruct = &SomeStruct { x: 11, y: 24.5 };
84
85     let unique_val: Box<_> = box SomeStruct { x: 13, y: 26.5 };
86     let unique_val_ref: &SomeStruct = &*unique_val;
87     let unique_val_interior_ref_1: &isize = &unique_val.x;
88     let unique_val_interior_ref_2: &f64 = &unique_val.y;
89
90     zzz(); // #break
91 }
92
93 fn zzz() {()}