diff options
| author | bors <bors@rust-lang.org> | 2019-06-11 11:06:38 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-06-11 11:06:38 +0000 |
| commit | 8e948df707ea8a3c88c65bf2ffdcb2f1cf5491be (patch) | |
| tree | caf2cb5f0b7881b6056c37c37c2e73e46b520aab /src/test/codegen/repr-transparent.rs | |
| parent | 912d22e36965d3c9f6d7f14ca18657182aa1fe54 (diff) | |
| parent | dac1c6a731713ec9e90a1e05b3e2c789faf3f2ba (diff) | |
Auto merge of #60463 - mjbshaw:transparent, r=varkor,rkruppe
Implement RFC 2645 (transparent enums and unions) Tracking issue: #60405
Diffstat (limited to 'src/test/codegen/repr-transparent.rs')
| -rw-r--r-- | src/test/codegen/repr-transparent.rs | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/src/test/codegen/repr-transparent.rs b/src/test/codegen/repr-transparent.rs index fd655261ab8..c9f38375658 100644 --- a/src/test/codegen/repr-transparent.rs +++ b/src/test/codegen/repr-transparent.rs @@ -1,13 +1,16 @@ // compile-flags: -C no-prepopulate-passes #![crate_type="lib"] -#![feature(repr_simd)] +#![feature(repr_simd, transparent_enums, transparent_unions)] use std::marker::PhantomData; +#[derive(Copy, Clone)] pub struct Zst1; +#[derive(Copy, Clone)] pub struct Zst2(()); +#[derive(Copy, Clone)] #[repr(transparent)] pub struct F32(f32); @@ -112,6 +115,44 @@ pub struct StructWithProjection(<f32 as Mirror>::It); #[no_mangle] pub extern fn test_Projection(_: StructWithProjection) -> StructWithProjection { loop {} } +#[repr(transparent)] +pub enum EnumF32 { + Variant(F32) +} + +// CHECK: define float @test_EnumF32(float %arg0) +#[no_mangle] +pub extern fn test_EnumF32(_: EnumF32) -> EnumF32 { loop {} } + +#[repr(transparent)] +pub enum EnumF32WithZsts { + Variant(Zst1, F32, Zst2) +} + +// CHECK: define float @test_EnumF32WithZsts(float %arg0) +#[no_mangle] +pub extern fn test_EnumF32WithZsts(_: EnumF32WithZsts) -> EnumF32WithZsts { loop {} } + +#[repr(transparent)] +pub union UnionF32 { + field: F32, +} + +// CHECK: define float @test_UnionF32(float %arg0) +#[no_mangle] +pub extern fn test_UnionF32(_: UnionF32) -> UnionF32 { loop {} } + +#[repr(transparent)] +pub union UnionF32WithZsts { + zst1: Zst1, + field: F32, + zst2: Zst2, +} + +// CHECK: define float @test_UnionF32WithZsts(float %arg0) +#[no_mangle] +pub extern fn test_UnionF32WithZsts(_: UnionF32WithZsts) -> UnionF32WithZsts { loop {} } + // All that remains to be tested are aggregates. They are tested in separate files called repr- // transparent-*.rs with `only-*` or `ignore-*` directives, because the expected LLVM IR |
