diff options
| author | bors <bors@rust-lang.org> | 2017-11-28 08:04:58 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-11-28 08:04:58 +0000 |
| commit | 436ac8928aa2e94f621111d6d99901713060b568 (patch) | |
| tree | f0abcf68b1f974a58c02d5f7571cf2f30fee373e /src/libstd/sys/unix/stack_overflow.rs | |
| parent | 7745a7a8177259cd2ea0b48eaf35dd943eec2896 (diff) | |
| parent | 0e63d2727c3215fab617a64c0a159ea871f4819c (diff) | |
| download | rust-436ac8928aa2e94f621111d6d99901713060b568.tar.gz rust-436ac8928aa2e94f621111d6d99901713060b568.zip | |
Auto merge of #46123 - Gankro:c-repr, r=eddyb
Implement the special repr(C)-non-clike-enum layout
This is the second half of https://github.com/rust-lang/rfcs/pull/2195
which specifies that
```rust
#[repr(C, u8)]
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
enum MyEnum {
A(u32), // Single primitive value
B { x: u8, y: i16 }, // Composite, and the offset of `y` depends on tag being internal
C, // Empty
D(Option<u32>), // Contains an enum
E(Duration), // Contains a struct
}
```
Has the same layout as
```rust
#[repr(C)]
struct MyEnumRepr {
tag: MyEnumTag,
payload: MyEnumPayload,
}
#[repr(C)]
#[allow(non_snake_case)]
union MyEnumPayload {
A: MyEnumVariantA,
B: MyEnumVariantB,
D: MyEnumVariantD,
E: MyEnumVariantE,
}
#[repr(u8)] #[derive(Copy, Clone)] enum MyEnumTag { A, B, C, D, E }
#[repr(C)] #[derive(Copy, Clone)] struct MyEnumVariantA(u32);
#[repr(C)] #[derive(Copy, Clone)] struct MyEnumVariantB {x: u8, y: i16 }
#[repr(C)] #[derive(Copy, Clone)] struct MyEnumVariantD(Option<u32>);
#[repr(C)] #[derive(Copy, Clone)] struct MyEnumVariantE(Duration);
```
Diffstat (limited to 'src/libstd/sys/unix/stack_overflow.rs')
0 files changed, 0 insertions, 0 deletions
