]> git.proxmox.com Git - rustc.git/blob - src/test/debuginfo/method-on-enum.rs
New upstream version 1.14.0+dfsg1
[rustc.git] / src / test / debuginfo / method-on-enum.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 // ignore-tidy-linelength
12 // min-lldb-version: 310
13
14 // compile-flags:-g
15
16 // === GDB TESTS ===================================================================================
17
18 // gdb-command:run
19
20 // STACK BY REF
21 // gdb-command:print *self
22 // gdbg-check:$1 = {{RUST$ENUM$DISR = Variant2, [...]}, {RUST$ENUM$DISR = Variant2, __0 = 117901063}}
23 // gdbr-check:$1 = method_on_enum::Enum::Variant2(117901063)
24 // gdb-command:print arg1
25 // gdb-check:$2 = -1
26 // gdb-command:print arg2
27 // gdb-check:$3 = -2
28 // gdb-command:continue
29
30 // STACK BY VAL
31 // gdb-command:print self
32 // gdbg-check:$4 = {{RUST$ENUM$DISR = Variant2, [...]}, {RUST$ENUM$DISR = Variant2, __0 = 117901063}}
33 // gdbr-check:$4 = method_on_enum::Enum::Variant2(117901063)
34 // gdb-command:print arg1
35 // gdb-check:$5 = -3
36 // gdb-command:print arg2
37 // gdb-check:$6 = -4
38 // gdb-command:continue
39
40 // OWNED BY REF
41 // gdb-command:print *self
42 // gdbg-check:$7 = {{RUST$ENUM$DISR = Variant1, x = 1799, y = 1799}, {RUST$ENUM$DISR = Variant1, [...]}}
43 // gdbr-check:$7 = method_on_enum::Enum::Variant1{x: 1799, y: 1799}
44 // gdb-command:print arg1
45 // gdb-check:$8 = -5
46 // gdb-command:print arg2
47 // gdb-check:$9 = -6
48 // gdb-command:continue
49
50 // OWNED BY VAL
51 // gdb-command:print self
52 // gdbg-check:$10 = {{RUST$ENUM$DISR = Variant1, x = 1799, y = 1799}, {RUST$ENUM$DISR = Variant1, [...]}}
53 // gdbr-check:$10 = method_on_enum::Enum::Variant1{x: 1799, y: 1799}
54 // gdb-command:print arg1
55 // gdb-check:$11 = -7
56 // gdb-command:print arg2
57 // gdb-check:$12 = -8
58 // gdb-command:continue
59
60 // OWNED MOVED
61 // gdb-command:print *self
62 // gdbg-check:$13 = {{RUST$ENUM$DISR = Variant1, x = 1799, y = 1799}, {RUST$ENUM$DISR = Variant1, [...]}}
63 // gdbr-check:$13 = method_on_enum::Enum::Variant1{x: 1799, y: 1799}
64 // gdb-command:print arg1
65 // gdb-check:$14 = -9
66 // gdb-command:print arg2
67 // gdb-check:$15 = -10
68 // gdb-command:continue
69
70
71 // === LLDB TESTS ==================================================================================
72
73 // lldb-command:run
74
75 // STACK BY REF
76 // lldb-command:print *self
77 // lldb-check:[...]$0 = Variant2(117901063)
78 // lldb-command:print arg1
79 // lldb-check:[...]$1 = -1
80 // lldb-command:print arg2
81 // lldb-check:[...]$2 = -2
82 // lldb-command:continue
83
84 // STACK BY VAL
85 // lldb-command:print self
86 // lldb-check:[...]$3 = Variant2(117901063)
87 // lldb-command:print arg1
88 // lldb-check:[...]$4 = -3
89 // lldb-command:print arg2
90 // lldb-check:[...]$5 = -4
91 // lldb-command:continue
92
93 // OWNED BY REF
94 // lldb-command:print *self
95 // lldb-check:[...]$6 = Variant1 { x: 1799, y: 1799 }
96 // lldb-command:print arg1
97 // lldb-check:[...]$7 = -5
98 // lldb-command:print arg2
99 // lldb-check:[...]$8 = -6
100 // lldb-command:continue
101
102 // OWNED BY VAL
103 // lldb-command:print self
104 // lldb-check:[...]$9 = Variant1 { x: 1799, y: 1799 }
105 // lldb-command:print arg1
106 // lldb-check:[...]$10 = -7
107 // lldb-command:print arg2
108 // lldb-check:[...]$11 = -8
109 // lldb-command:continue
110
111 // OWNED MOVED
112 // lldb-command:print *self
113 // lldb-check:[...]$12 = Variant1 { x: 1799, y: 1799 }
114 // lldb-command:print arg1
115 // lldb-check:[...]$13 = -9
116 // lldb-command:print arg2
117 // lldb-check:[...]$14 = -10
118 // lldb-command:continue
119
120 #![feature(box_syntax)]
121 #![feature(omit_gdb_pretty_printer_section)]
122 #![omit_gdb_pretty_printer_section]
123
124 #[derive(Copy, Clone)]
125 enum Enum {
126 Variant1 { x: u16, y: u16 },
127 Variant2 (u32)
128 }
129
130 impl Enum {
131
132 fn self_by_ref(&self, arg1: isize, arg2: isize) -> isize {
133 zzz(); // #break
134 arg1 + arg2
135 }
136
137 fn self_by_val(self, arg1: isize, arg2: isize) -> isize {
138 zzz(); // #break
139 arg1 + arg2
140 }
141
142 fn self_owned(self: Box<Enum>, arg1: isize, arg2: isize) -> isize {
143 zzz(); // #break
144 arg1 + arg2
145 }
146 }
147
148 fn main() {
149 let stack = Enum::Variant2(117901063);
150 let _ = stack.self_by_ref(-1, -2);
151 let _ = stack.self_by_val(-3, -4);
152
153 let owned: Box<_> = box Enum::Variant1{ x: 1799, y: 1799 };
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() {()}