]> git.lizzy.rs Git - rust.git/blob - src/test/codegen/enum-debug-niche-2.rs
Suggest defining type parameter when appropriate
[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 #![feature(never_type)]
16
17 #[derive(Copy, Clone)]
18 pub struct Entity {
19     private: std::num::NonZeroU32,
20 }
21
22 #[derive(Copy, Clone, PartialEq, Eq)]
23 pub struct Declaration;
24
25 impl TypeFamily for Declaration {
26     type Base = Base;
27     type Placeholder = !;
28
29     fn intern_base_data(_: BaseKind<Self>) {}
30 }
31
32 #[derive(Copy, Clone)]
33 pub struct Base;
34
35 pub trait TypeFamily: Copy + 'static {
36     type Base: Copy;
37     type Placeholder: Copy;
38
39     fn intern_base_data(_: BaseKind<Self>);
40 }
41
42 #[derive(Copy, Clone)]
43 pub enum BaseKind<F: TypeFamily> {
44     Named(Entity),
45     Placeholder(F::Placeholder),
46     Error,
47 }
48
49 pub fn main() {
50     let x = BaseKind::Error::<Declaration>;
51     let y = 7;
52 }