]> git.lizzy.rs Git - rust.git/blob - src/test/debuginfo/associated-types.rs
Rollup merge of #51722 - Aaronepower:master, r=Mark-Simulacrum
[rust.git] / src / test / debuginfo / associated-types.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 // gdb-command:run
17
18 // gdb-command:print arg
19 // gdbg-check:$1 = {b = -1, b1 = 0}
20 // gdbr-check:$1 = associated_types::Struct<i32> {b: -1, b1: 0}
21 // gdb-command:continue
22
23 // gdb-command:print inferred
24 // gdb-check:$2 = 1
25 // gdb-command:print explicitly
26 // gdb-check:$3 = 1
27 // gdb-command:continue
28
29 // gdb-command:print arg
30 // gdb-check:$4 = 2
31 // gdb-command:continue
32
33 // gdb-command:print arg
34 // gdbg-check:$5 = {__0 = 4, __1 = 5}
35 // gdbr-check:$5 = (4, 5)
36 // gdb-command:continue
37
38 // gdb-command:print a
39 // gdb-check:$6 = 6
40 // gdb-command:print b
41 // gdb-check:$7 = 7
42 // gdb-command:continue
43
44 // gdb-command:print a
45 // gdb-check:$8 = 8
46 // gdb-command:print b
47 // gdb-check:$9 = 9
48 // gdb-command:continue
49
50 // === LLDB TESTS ==================================================================================
51 // lldb-command:run
52
53 // lldb-command:print arg
54 // lldb-check:[...]$0 = Struct<i32> { b: -1, b1: 0 }
55 // lldb-command:continue
56
57 // lldb-command:print inferred
58 // lldb-check:[...]$1 = 1
59 // lldb-command:print explicitly
60 // lldb-check:[...]$2 = 1
61 // lldb-command:continue
62
63 // lldb-command:print arg
64 // lldb-check:[...]$3 = 2
65 // lldb-command:continue
66
67 // lldb-command:print arg
68 // lldb-check:[...]$4 = (4, 5)
69 // lldb-command:continue
70
71 // lldb-command:print a
72 // lldb-check:[...]$5 = 6
73 // lldb-command:print b
74 // lldb-check:[...]$6 = 7
75 // lldb-command:continue
76
77 // lldb-command:print a
78 // lldb-check:[...]$7 = 8
79 // lldb-command:print b
80 // lldb-check:[...]$8 = 9
81 // lldb-command:continue
82
83 #![allow(unused_variables)]
84 #![allow(dead_code)]
85 #![feature(omit_gdb_pretty_printer_section)]
86 #![omit_gdb_pretty_printer_section]
87
88 trait TraitWithAssocType {
89     type Type;
90
91     fn get_value(&self) -> Self::Type;
92 }
93 impl TraitWithAssocType for i32 {
94     type Type = i64;
95
96     fn get_value(&self) -> i64 { *self as i64 }
97 }
98
99 struct Struct<T: TraitWithAssocType> {
100     b: T,
101     b1: T::Type,
102 }
103
104 enum Enum<T: TraitWithAssocType> {
105     Variant1(T, T::Type),
106     Variant2(T::Type, T)
107 }
108
109 fn assoc_struct<T: TraitWithAssocType>(arg: Struct<T>) {
110     zzz(); // #break
111 }
112
113 fn assoc_local<T: TraitWithAssocType>(x: T) {
114     let inferred = x.get_value();
115     let explicitly: T::Type = x.get_value();
116
117     zzz(); // #break
118 }
119
120 fn assoc_arg<T: TraitWithAssocType>(arg: T::Type) {
121     zzz(); // #break
122 }
123
124 fn assoc_return_value<T: TraitWithAssocType>(arg: T) -> T::Type {
125     return arg.get_value();
126 }
127
128 fn assoc_tuple<T: TraitWithAssocType>(arg: (T, T::Type)) {
129     zzz(); // #break
130 }
131
132 fn assoc_enum<T: TraitWithAssocType>(arg: Enum<T>) {
133
134     match arg {
135         Enum::Variant1(a, b) => {
136             zzz(); // #break
137         }
138         Enum::Variant2(a, b) => {
139             zzz(); // #break
140         }
141     }
142 }
143
144 fn main() {
145     assoc_struct(Struct { b: -1, b1: 0 });
146     assoc_local(1);
147     assoc_arg::<i32>(2);
148     assoc_return_value(3);
149     assoc_tuple((4, 5));
150     assoc_enum(Enum::Variant1(6, 7));
151     assoc_enum(Enum::Variant2(8, 9));
152 }
153
154 fn zzz() { () }