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