]> git.lizzy.rs Git - rust.git/blob - src/test/codegen/enum-debug-niche-2.rs
Auto merge of #66322 - lzutao:consistent-result-map_or_else, r=dtolnay
[rust.git] / src / test / codegen / enum-debug-niche-2.rs
1 // This test depends on a patch that was committed to upstream LLVM
2 // before 7.0, then backported to the Rust LLVM fork.  It tests that
3 // optimized enum debug info accurately reflects the enum layout.
4
5 // ignore-tidy-linelength
6 // ignore-windows
7 // min-system-llvm-version 8.0
8
9 // compile-flags: -g -C no-prepopulate-passes
10
11 // CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_variant_part,{{.*}}size: 32,{{.*}}
12 // CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "Placeholder",{{.*}}extraData: i64 4294967295{{[,)].*}}
13 // CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "Error",{{.*}}extraData: i64 0{{[,)].*}}
14
15 #[derive(Copy, Clone)]
16 pub struct Entity {
17     private: std::num::NonZeroU32,
18 }
19
20 #[derive(Copy, Clone, PartialEq, Eq)]
21 pub struct Declaration;
22
23 impl TypeFamily for Declaration {
24     type Base = Base;
25     type Placeholder = !;
26
27     fn intern_base_data(_: BaseKind<Self>) {}
28 }
29
30 #[derive(Copy, Clone)]
31 pub struct Base;
32
33 pub trait TypeFamily: Copy + 'static {
34     type Base: Copy;
35     type Placeholder: Copy;
36
37     fn intern_base_data(_: BaseKind<Self>);
38 }
39
40 #[derive(Copy, Clone)]
41 pub enum BaseKind<F: TypeFamily> {
42     Named(Entity),
43     Placeholder(F::Placeholder),
44     Error,
45 }
46
47 pub fn main() {
48     let x = BaseKind::Error::<Declaration>;
49     let y = 7;
50 }