]> git.proxmox.com Git - rustc.git/blob - src/test/debuginfo/generic-method-on-generic-struct.rs
New upstream version 1.14.0+dfsg1
[rustc.git] / src / test / debuginfo / generic-method-on-generic-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
12 // compile-flags:-g
13 // min-lldb-version: 310
14
15 // === GDB TESTS ===================================================================================
16
17 // gdb-command:run
18
19 // STACK BY REF
20 // gdb-command:print *self
21 // gdbg-check:$1 = {x = {__0 = 8888, __1 = -8888}}
22 // gdbr-check:$1 = generic_method_on_generic_struct::Struct<(u32, i32)> {x: (8888, -8888)}
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 = {__0 = 8888, __1 = -8888}}
32 // gdbr-check:$4 = generic_method_on_generic_struct::Struct<(u32, i32)> {x: (8888, -8888)}
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 = 1234.5}
42 // gdbr-check:$7 = generic_method_on_generic_struct::Struct<f64> {x: 1234.5}
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 = 1234.5}
52 // gdbr-check:$10 = generic_method_on_generic_struct::Struct<f64> {x: 1234.5}
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 = 1234.5}
62 // gdbr-check:$13 = generic_method_on_generic_struct::Struct<f64> {x: 1234.5}
63 // gdb-command:print arg1
64 // gdb-check:$14 = -9
65 // gdb-command:print arg2
66 // gdb-check:$15 = -10.5
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 // lldb-check:[...]$0 = Struct<(u32, i32)> { x: (8888, -8888) }
77 // lldb-command:print arg1
78 // lldb-check:[...]$1 = -1
79 // lldb-command:print arg2
80 // lldb-check:[...]$2 = 2
81 // lldb-command:continue
82
83 // STACK BY VAL
84 // lldb-command:print self
85 // lldb-check:[...]$3 = Struct<(u32, i32)> { x: (8888, -8888) }
86 // lldb-command:print arg1
87 // lldb-check:[...]$4 = -3
88 // lldb-command:print arg2
89 // lldb-check:[...]$5 = -4
90 // lldb-command:continue
91
92 // OWNED BY REF
93 // lldb-command:print *self
94 // lldb-check:[...]$6 = Struct<f64> { x: 1234.5 }
95 // lldb-command:print arg1
96 // lldb-check:[...]$7 = -5
97 // lldb-command:print arg2
98 // lldb-check:[...]$8 = -6
99 // lldb-command:continue
100
101 // OWNED BY VAL
102 // lldb-command:print self
103 // lldb-check:[...]$9 = Struct<f64> { x: 1234.5 }
104 // lldb-command:print arg1
105 // lldb-check:[...]$10 = -7
106 // lldb-command:print arg2
107 // lldb-check:[...]$11 = -8
108 // lldb-command:continue
109
110 // OWNED MOVED
111 // lldb-command:print *self
112 // lldb-check:[...]$12 = Struct<f64> { x: 1234.5 }
113 // lldb-command:print arg1
114 // lldb-check:[...]$13 = -9
115 // lldb-command:print arg2
116 // lldb-check:[...]$14 = -10.5
117 // lldb-command:continue
118
119 #![feature(box_syntax)]
120 #![feature(omit_gdb_pretty_printer_section)]
121 #![omit_gdb_pretty_printer_section]
122
123 #[derive(Copy, Clone)]
124 struct Struct<T> {
125 x: T
126 }
127
128 impl<T1> Struct<T1> {
129
130 fn self_by_ref<T2>(&self, arg1: isize, arg2: T2) -> isize {
131 zzz(); // #break
132 arg1
133 }
134
135 fn self_by_val<T2>(self, arg1: isize, arg2: T2) -> isize {
136 zzz(); // #break
137 arg1
138 }
139
140 fn self_owned<T2>(self: Box<Struct<T1>>, arg1: isize, arg2: T2) -> isize {
141 zzz(); // #break
142 arg1
143 }
144 }
145
146 fn main() {
147 let stack = Struct { x: (8888_u32, -8888_i32) };
148 let _ = stack.self_by_ref(-1, 2_u16);
149 let _ = stack.self_by_val(-3, -4_i16);
150
151 let owned: Box<_> = box Struct { x: 1234.5f64 };
152 let _ = owned.self_by_ref(-5, -6_i32);
153 let _ = owned.self_by_val(-7, -8_i64);
154 let _ = owned.self_owned(-9, -10.5_f32);
155 }
156
157 fn zzz() {()}