|
| 1 | +// Copyright 2018 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 | +// This test depends on a patch that was committed to upstream LLVM |
| 12 | +// before 7.0, then backported to the Rust LLVM fork. It tests that |
| 13 | +// optimized enum debug info accurately reflects the enum layout. |
| 14 | + |
| 15 | +// ignore-tidy-linelength |
| 16 | +// ignore-windows |
| 17 | +// min-system-llvm-version 7.0 |
| 18 | + |
| 19 | +// compile-flags: -g -C no-prepopulate-passes |
| 20 | + |
| 21 | +// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_variant_part,{{.*}}size: 32,{{.*}} |
| 22 | +// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "Placeholder",{{.*}}extraData: i64 4294967295{{[,)].*}} |
| 23 | +// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "Error",{{.*}}extraData: i64 0{{[,)].*}} |
| 24 | + |
| 25 | +#![feature(never_type)] |
| 26 | +#![feature(nll)] |
| 27 | + |
| 28 | +#[derive(Copy, Clone)] |
| 29 | +pub struct Entity { |
| 30 | + private: std::num::NonZeroU32, |
| 31 | +} |
| 32 | + |
| 33 | +#[derive(Copy, Clone, PartialEq, Eq)] |
| 34 | +pub struct Declaration; |
| 35 | + |
| 36 | +impl TypeFamily for Declaration { |
| 37 | + type Base = Base; |
| 38 | + type Placeholder = !; |
| 39 | + |
| 40 | + fn intern_base_data(_: BaseKind<Self>) {} |
| 41 | +} |
| 42 | + |
| 43 | +#[derive(Copy, Clone)] |
| 44 | +pub struct Base; |
| 45 | + |
| 46 | +pub trait TypeFamily: Copy + 'static { |
| 47 | + type Base: Copy; |
| 48 | + type Placeholder: Copy; |
| 49 | + |
| 50 | + fn intern_base_data(_: BaseKind<Self>); |
| 51 | +} |
| 52 | + |
| 53 | +#[derive(Copy, Clone)] |
| 54 | +pub enum BaseKind<F: TypeFamily> { |
| 55 | + Named(Entity), |
| 56 | + Placeholder(F::Placeholder), |
| 57 | + Error, |
| 58 | +} |
| 59 | + |
| 60 | +pub fn main() { |
| 61 | + let x = BaseKind::Error::<Declaration>; |
| 62 | + let y = 7; |
| 63 | +} |
0 commit comments