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