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