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