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