]> git.proxmox.com Git - rustc.git/blob - src/test/debuginfo/generic-enum-with-different-disr-sizes.rs
New upstream version 1.66.0+dfsg1
[rustc.git] / src / test / debuginfo / generic-enum-with-different-disr-sizes.rs
1 // ignore-lldb: FIXME(#27089)
2 // min-lldb-version: 310
3
4 // Require a gdb that can read DW_TAG_variant_part.
5 // min-gdb-version: 8.2
6
7 // compile-flags:-g
8
9 // === GDB TESTS ===================================================================================
10 // gdb-command:run
11
12 // gdb-command:print eight_bytes1
13 // gdbr-check:$1 = generic_enum_with_different_disr_sizes::Enum<f64>::Variant1(100)
14
15 // gdb-command:print four_bytes1
16 // gdbr-check:$2 = generic_enum_with_different_disr_sizes::Enum<i32>::Variant1(101)
17
18 // gdb-command:print two_bytes1
19 // gdbr-check:$3 = generic_enum_with_different_disr_sizes::Enum<i16>::Variant1(102)
20
21 // gdb-command:print one_byte1
22 // gdbr-check:$4 = generic_enum_with_different_disr_sizes::Enum<u8>::Variant1(65)
23
24
25 // gdb-command:print eight_bytes2
26 // gdbr-check:$5 = generic_enum_with_different_disr_sizes::Enum<f64>::Variant2(100)
27
28 // gdb-command:print four_bytes2
29 // gdbr-check:$6 = generic_enum_with_different_disr_sizes::Enum<i32>::Variant2(101)
30
31 // gdb-command:print two_bytes2
32 // gdbr-check:$7 = generic_enum_with_different_disr_sizes::Enum<i16>::Variant2(102)
33
34 // gdb-command:print one_byte2
35 // gdbr-check:$8 = generic_enum_with_different_disr_sizes::Enum<u8>::Variant2(65)
36
37 // gdb-command:continue
38
39 // === LLDB TESTS ==================================================================================
40 // lldb-command:run
41
42 // lldb-command:print eight_bytes1
43 // lldb-check:[...]$0 = Variant1(100)
44 // lldb-command:print four_bytes1
45 // lldb-check:[...]$1 = Variant1(101)
46 // lldb-command:print two_bytes1
47 // lldb-check:[...]$2 = Variant1(102)
48 // lldb-command:print one_byte1
49 // lldb-check:[...]$3 = Variant1('A')
50
51 // lldb-command:print eight_bytes2
52 // lldb-check:[...]$4 = Variant2(100)
53 // lldb-command:print four_bytes2
54 // lldb-check:[...]$5 = Variant2(101)
55 // lldb-command:print two_bytes2
56 // lldb-check:[...]$6 = Variant2(102)
57 // lldb-command:print one_byte2
58 // lldb-check:[...]$7 = Variant2('A')
59
60 // lldb-command:continue
61
62 #![allow(unused_variables)]
63 #![allow(dead_code)]
64 #![feature(omit_gdb_pretty_printer_section)]
65 #![omit_gdb_pretty_printer_section]
66
67 // This test case makes sure that we get correct type descriptions for the enum
68 // discriminant of different instantiations of the same generic enum type where,
69 // dependending on the generic type parameter(s), the discriminant has a
70 // different size in memory.
71
72 enum Enum<T> {
73 Variant1(T),
74 Variant2(T)
75 }
76
77 fn main() {
78 // These are ordered for descending size on purpose
79 let eight_bytes1 = Enum::Variant1(100.0f64);
80 let four_bytes1 = Enum::Variant1(101i32);
81 let two_bytes1 = Enum::Variant1(102i16);
82 let one_byte1 = Enum::Variant1(65u8);
83
84 let eight_bytes2 = Enum::Variant2(100.0f64);
85 let four_bytes2 = Enum::Variant2(101i32);
86 let two_bytes2 = Enum::Variant2(102i16);
87 let one_byte2 = Enum::Variant2(65u8);
88
89 zzz(); // #break
90 }
91
92 fn zzz() { () }