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