]> git.lizzy.rs Git - rust.git/blob - src/test/debuginfo/borrowed-enum.rs
Auto merge of #82552 - GuillaumeGomez:rollup-8dn1ztn, r=GuillaumeGomez
[rust.git] / src / test / debuginfo / borrowed-enum.rs
1 // ignore-tidy-linelength
2
3 // Require a gdb or lldb that can read DW_TAG_variant_part.
4 // min-gdb-version: 8.2
5 // rust-lldb
6
7 // compile-flags:-g
8
9 // === GDB TESTS ===================================================================================
10
11 // gdb-command:run
12
13 // gdb-command:print *the_a_ref
14 // gdbr-check:$1 = borrowed_enum::ABC::TheA{x: 0, y: 8970181431921507452}
15
16 // gdb-command:print *the_b_ref
17 // gdbr-check:$2 = borrowed_enum::ABC::TheB(0, 286331153, 286331153)
18
19 // gdb-command:print *univariant_ref
20 // gdbr-check:$3 = borrowed_enum::Univariant::TheOnlyCase(4820353753753434)
21
22
23 // === LLDB TESTS ==================================================================================
24
25 // lldb-command:run
26
27 // lldb-command:print *the_a_ref
28 // lldbr-check:(borrowed_enum::ABC::TheA) *the_a_ref = TheA { TheA: 0, TheB: 8970181431921507452 }
29 // lldb-command:print *the_b_ref
30 // lldbr-check:(borrowed_enum::ABC::TheB) *the_b_ref = { = 0 = 286331153 = 286331153 }
31 // lldb-command:print *univariant_ref
32 // lldbr-check:(borrowed_enum::Univariant) *univariant_ref = { TheOnlyCase = { = 4820353753753434 } }
33
34 #![allow(unused_variables)]
35 #![feature(omit_gdb_pretty_printer_section)]
36 #![omit_gdb_pretty_printer_section]
37
38 // The first element is to ensure proper alignment, irrespective of the machines word size. Since
39 // the size of the discriminant value is machine dependent, this has be taken into account when
40 // datatype layout should be predictable as in this case.
41 enum ABC {
42     TheA { x: i64, y: i64 },
43     TheB (i64, i32, i32),
44 }
45
46 // This is a special case since it does not have the implicit discriminant field.
47 enum Univariant {
48     TheOnlyCase(i64)
49 }
50
51 fn main() {
52
53     // 0b0111110001111100011111000111110001111100011111000111110001111100 = 8970181431921507452
54     // 0b01111100011111000111110001111100 = 2088533116
55     // 0b0111110001111100 = 31868
56     // 0b01111100 = 124
57     let the_a = ABC::TheA { x: 0, y: 8970181431921507452 };
58     let the_a_ref: &ABC = &the_a;
59
60     // 0b0001000100010001000100010001000100010001000100010001000100010001 = 1229782938247303441
61     // 0b00010001000100010001000100010001 = 286331153
62     // 0b0001000100010001 = 4369
63     // 0b00010001 = 17
64     let the_b = ABC::TheB (0, 286331153, 286331153);
65     let the_b_ref: &ABC = &the_b;
66
67     let univariant = Univariant::TheOnlyCase(4820353753753434);
68     let univariant_ref: &Univariant = &univariant;
69
70     zzz(); // #break
71 }
72
73 fn zzz() {()}