]> git.lizzy.rs Git - rust.git/blob - src/test/debuginfo/generic-enum-with-different-disr-sizes.rs
Auto merge of #28816 - petrochenkov:unistruct, r=nrc
[rust.git] / src / test / debuginfo / generic-enum-with-different-disr-sizes.rs
1 // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // ignore-tidy-linelength
12 // ignore-lldb: FIXME(#27089)
13 // min-lldb-version: 310
14
15 // compile-flags:-g
16
17 // === GDB TESTS ===================================================================================
18 // gdb-command:run
19
20 // gdb-command:print eight_bytes1
21 // gdb-check:$1 = {{RUST$ENUM$DISR = Variant1, __0 = 100}, {RUST$ENUM$DISR = Variant1, __0 = 100}}
22 // gdb-command:print four_bytes1
23 // gdb-check:$2 = {{RUST$ENUM$DISR = Variant1, __0 = 101}, {RUST$ENUM$DISR = Variant1, __0 = 101}}
24 // gdb-command:print two_bytes1
25 // gdb-check:$3 = {{RUST$ENUM$DISR = Variant1, __0 = 102}, {RUST$ENUM$DISR = Variant1, __0 = 102}}
26 // gdb-command:print one_byte1
27 // gdb-check:$4 = {{RUST$ENUM$DISR = Variant1, __0 = 65 'A'}, {RUST$ENUM$DISR = Variant1, __0 = 65 'A'}}
28
29 // gdb-command:print eight_bytes2
30 // gdb-check:$5 = {{RUST$ENUM$DISR = Variant2, __0 = 100}, {RUST$ENUM$DISR = Variant2, __0 = 100}}
31 // gdb-command:print four_bytes2
32 // gdb-check:$6 = {{RUST$ENUM$DISR = Variant2, __0 = 101}, {RUST$ENUM$DISR = Variant2, __0 = 101}}
33 // gdb-command:print two_bytes2
34 // gdb-check:$7 = {{RUST$ENUM$DISR = Variant2, __0 = 102}, {RUST$ENUM$DISR = Variant2, __0 = 102}}
35 // gdb-command:print one_byte2
36 // gdb-check:$8 = {{RUST$ENUM$DISR = Variant2, __0 = 65 'A'}, {RUST$ENUM$DISR = Variant2, __0 = 65 'A'}}
37
38 // gdb-command:continue
39
40 // === LLDB TESTS ==================================================================================
41 // lldb-command:run
42
43 // lldb-command:print eight_bytes1
44 // lldb-check:[...]$0 = Variant1(100)
45 // lldb-command:print four_bytes1
46 // lldb-check:[...]$1 = Variant1(101)
47 // lldb-command:print two_bytes1
48 // lldb-check:[...]$2 = Variant1(102)
49 // lldb-command:print one_byte1
50 // lldb-check:[...]$3 = Variant1('A')
51
52 // lldb-command:print eight_bytes2
53 // lldb-check:[...]$4 = Variant2(100)
54 // lldb-command:print four_bytes2
55 // lldb-check:[...]$5 = Variant2(101)
56 // lldb-command:print two_bytes2
57 // lldb-check:[...]$6 = Variant2(102)
58 // lldb-command:print one_byte2
59 // lldb-check:[...]$7 = Variant2('A')
60
61 // lldb-command:continue
62
63 #![allow(unused_variables)]
64 #![allow(dead_code)]
65 #![feature(omit_gdb_pretty_printer_section)]
66 #![omit_gdb_pretty_printer_section]
67
68 // This test case makes sure that we get correct type descriptions for the enum
69 // discriminant of different instantiations of the same generic enum type where,
70 // dependending on the generic type parameter(s), the discriminant has a
71 // different size in memory.
72
73 enum Enum<T> {
74     Variant1(T),
75     Variant2(T)
76 }
77
78 fn main() {
79     // These are ordered for descending size on purpose
80     let eight_bytes1 = Enum::Variant1(100.0f64);
81     let four_bytes1 = Enum::Variant1(101i32);
82     let two_bytes1 = Enum::Variant1(102i16);
83     let one_byte1 = Enum::Variant1(65u8);
84
85     let eight_bytes2 = Enum::Variant2(100.0f64);
86     let four_bytes2 = Enum::Variant2(101i32);
87     let two_bytes2 = Enum::Variant2(102i16);
88     let one_byte2 = Enum::Variant2(65u8);
89
90     zzz(); // #break
91 }
92
93 fn zzz() { () }