]> git.lizzy.rs Git - rust.git/blob - src/test/debuginfo/method-on-struct.rs
Rollup merge of #54909 - scalexm:finish-rules, r=nikomatsakis
[rust.git] / src / test / debuginfo / method-on-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 // min-lldb-version: 310
12
13 // compile-flags:-g
14
15 // === GDB TESTS ===================================================================================
16
17 // gdb-command:run
18
19 // STACK BY REF
20 // gdb-command:print *self
21 // gdbg-check:$1 = {x = 100}
22 // gdbr-check:$1 = method_on_struct::Struct {x: 100}
23 // gdb-command:print arg1
24 // gdb-check:$2 = -1
25 // gdb-command:print arg2
26 // gdb-check:$3 = -2
27 // gdb-command:continue
28
29 // STACK BY VAL
30 // gdb-command:print self
31 // gdbg-check:$4 = {x = 100}
32 // gdbr-check:$4 = method_on_struct::Struct {x: 100}
33 // gdb-command:print arg1
34 // gdb-check:$5 = -3
35 // gdb-command:print arg2
36 // gdb-check:$6 = -4
37 // gdb-command:continue
38
39 // OWNED BY REF
40 // gdb-command:print *self
41 // gdbg-check:$7 = {x = 200}
42 // gdbr-check:$7 = method_on_struct::Struct {x: 200}
43 // gdb-command:print arg1
44 // gdb-check:$8 = -5
45 // gdb-command:print arg2
46 // gdb-check:$9 = -6
47 // gdb-command:continue
48
49 // OWNED BY VAL
50 // gdb-command:print self
51 // gdbg-check:$10 = {x = 200}
52 // gdbr-check:$10 = method_on_struct::Struct {x: 200}
53 // gdb-command:print arg1
54 // gdb-check:$11 = -7
55 // gdb-command:print arg2
56 // gdb-check:$12 = -8
57 // gdb-command:continue
58
59 // OWNED MOVED
60 // gdb-command:print *self
61 // gdbg-check:$13 = {x = 200}
62 // gdbr-check:$13 = method_on_struct::Struct {x: 200}
63 // gdb-command:print arg1
64 // gdb-check:$14 = -9
65 // gdb-command:print arg2
66 // gdb-check:$15 = -10
67 // gdb-command:continue
68
69
70 // === LLDB TESTS ==================================================================================
71
72 // lldb-command:run
73
74 // STACK BY REF
75 // lldb-command:print *self
76 // lldbg-check:[...]$0 = Struct { x: 100 }
77 // lldbr-check:(method_on_struct::Struct) *self = Struct { x: 100 }
78 // lldb-command:print arg1
79 // lldbg-check:[...]$1 = -1
80 // lldbr-check:(isize) arg1 = -1
81 // lldb-command:print arg2
82 // lldbg-check:[...]$2 = -2
83 // lldbr-check:(isize) arg2 = -2
84 // lldb-command:continue
85
86 // STACK BY VAL
87 // lldb-command:print self
88 // lldbg-check:[...]$3 = Struct { x: 100 }
89 // lldbr-check:(method_on_struct::Struct) self = Struct { x: 100 }
90 // lldb-command:print arg1
91 // lldbg-check:[...]$4 = -3
92 // lldbr-check:(isize) arg1 = -3
93 // lldb-command:print arg2
94 // lldbg-check:[...]$5 = -4
95 // lldbr-check:(isize) arg2 = -4
96 // lldb-command:continue
97
98 // OWNED BY REF
99 // lldb-command:print *self
100 // lldbg-check:[...]$6 = Struct { x: 200 }
101 // lldbr-check:(method_on_struct::Struct) *self = Struct { x: 200 }
102 // lldb-command:print arg1
103 // lldbg-check:[...]$7 = -5
104 // lldbr-check:(isize) arg1 = -5
105 // lldb-command:print arg2
106 // lldbg-check:[...]$8 = -6
107 // lldbr-check:(isize) arg2 = -6
108 // lldb-command:continue
109
110 // OWNED BY VAL
111 // lldb-command:print self
112 // lldbg-check:[...]$9 = Struct { x: 200 }
113 // lldbr-check:(method_on_struct::Struct) self = Struct { x: 200 }
114 // lldb-command:print arg1
115 // lldbg-check:[...]$10 = -7
116 // lldbr-check:(isize) arg1 = -7
117 // lldb-command:print arg2
118 // lldbg-check:[...]$11 = -8
119 // lldbr-check:(isize) arg2 = -8
120 // lldb-command:continue
121
122 // OWNED MOVED
123 // lldb-command:print *self
124 // lldbg-check:[...]$12 = Struct { x: 200 }
125 // lldbr-check:(method_on_struct::Struct) *self = Struct { x: 200 }
126 // lldb-command:print arg1
127 // lldbg-check:[...]$13 = -9
128 // lldbr-check:(isize) arg1 = -9
129 // lldb-command:print arg2
130 // lldbg-check:[...]$14 = -10
131 // lldbr-check:(isize) arg2 = -10
132 // lldb-command:continue
133
134
135 #![feature(box_syntax)]
136 #![feature(omit_gdb_pretty_printer_section)]
137 #![omit_gdb_pretty_printer_section]
138
139 #[derive(Copy, Clone)]
140 struct Struct {
141     x: isize
142 }
143
144 impl Struct {
145
146     fn self_by_ref(&self, arg1: isize, arg2: isize) -> isize {
147         zzz(); // #break
148         self.x + arg1 + arg2
149     }
150
151     fn self_by_val(self, arg1: isize, arg2: isize) -> isize {
152         zzz(); // #break
153         self.x + arg1 + arg2
154     }
155
156     fn self_owned(self: Box<Struct>, arg1: isize, arg2: isize) -> isize {
157         zzz(); // #break
158         self.x + arg1 + arg2
159     }
160 }
161
162 fn main() {
163     let stack = Struct { x: 100 };
164     let _ = stack.self_by_ref(-1, -2);
165     let _ = stack.self_by_val(-3, -4);
166
167     let owned: Box<_> = box Struct { x: 200 };
168     let _ = owned.self_by_ref(-5, -6);
169     let _ = owned.self_by_val(-7, -8);
170     let _ = owned.self_owned(-9, -10);
171 }
172
173 fn zzz() {()}