]> git.lizzy.rs Git - rust.git/blob - tests/debuginfo/struct-in-enum.rs
Rollup merge of #107780 - compiler-errors:instantiate-binder, r=lcnr
[rust.git] / tests / debuginfo / struct-in-enum.rs
1 // min-lldb-version: 310
2 // ignore-gdb-version: 7.11.90 - 7.12.9
3 // ignore-test // Test temporarily ignored due to debuginfo tests being disabled, see PR 47155
4
5 // compile-flags:-g
6
7 // === GDB TESTS ===================================================================================
8
9 // gdb-command:set print union on
10 // gdb-command:run
11
12 // gdb-command:print case1
13 // gdbg-check:$1 = {{RUST$ENUM$DISR = Case1, __0 = 0, __1 = {x = 2088533116, y = 2088533116, z = 31868}}, {RUST$ENUM$DISR = Case1, [...]}}
14 // gdbr-check:$1 = struct_in_enum::Regular::Case1(0, struct_in_enum::Struct {x: 2088533116, y: 2088533116, z: 31868})
15
16 // gdb-command:print case2
17 // gdbg-check:$2 = {{RUST$ENUM$DISR = Case2, [...]}, {RUST$ENUM$DISR = Case2, __0 = 0, __1 = 1229782938247303441, __2 = 4369}}
18 // gdbr-check:$2 = struct_in_enum::Regular::Case2(0, 1229782938247303441, 4369)
19
20 // gdb-command:print univariant
21 // gdbg-check:$3 = {{__0 = {x = 123, y = 456, z = 789}}}
22 // gdbr-check:$3 = struct_in_enum::Univariant::TheOnlyCase(struct_in_enum::Struct {x: 123, y: 456, z: 789})
23
24
25 // === LLDB TESTS ==================================================================================
26
27 // lldb-command:run
28
29 // lldb-command:print case1
30 // lldb-check:[...]$0 = Case1(0, Struct { x: 2088533116, y: 2088533116, z: 31868 })
31 // lldb-command:print case2
32 // lldb-check:[...]$1 = Case2(0, 1229782938247303441, 4369)
33
34 // lldb-command:print univariant
35 // lldb-check:[...]$2 = TheOnlyCase(Struct { x: 123, y: 456, z: 789 })
36
37 #![allow(unused_variables)]
38 #![feature(omit_gdb_pretty_printer_section)]
39 #![omit_gdb_pretty_printer_section]
40
41 use self::Regular::{Case1, Case2};
42 use self::Univariant::TheOnlyCase;
43
44 struct Struct {
45     x: u32,
46     y: i32,
47     z: i16
48 }
49
50 // The first element is to ensure proper alignment, irrespective of the machines word size. Since
51 // the size of the discriminant value is machine dependent, this has be taken into account when
52 // datatype layout should be predictable as in this case.
53 enum Regular {
54     Case1(u64, Struct),
55     Case2(u64, u64, i16)
56 }
57
58 enum Univariant {
59     TheOnlyCase(Struct)
60 }
61
62 fn main() {
63
64     // In order to avoid endianness trouble all of the following test values consist of a single
65     // repeated byte. This way each interpretation of the union should look the same, no matter if
66     // this is a big or little endian machine.
67
68     // 0b0111110001111100011111000111110001111100011111000111110001111100 = 8970181431921507452
69     // 0b01111100011111000111110001111100 = 2088533116
70     // 0b0111110001111100 = 31868
71     // 0b01111100 = 124
72     let case1 = Case1(0, Struct { x: 2088533116, y: 2088533116, z: 31868 });
73
74     // 0b0001000100010001000100010001000100010001000100010001000100010001 = 1229782938247303441
75     // 0b00010001000100010001000100010001 = 286331153
76     // 0b0001000100010001 = 4369
77     // 0b00010001 = 17
78     let case2 = Case2(0, 1229782938247303441, 4369);
79
80     let univariant = TheOnlyCase(Struct { x: 123, y: 456, z: 789 });
81
82     zzz(); // #break
83 }
84
85 fn zzz() {()}