about summary refs log tree commit diff
path: root/src/liballoc_system
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-08-07 13:14:37 +0000
committerbors <bors@rust-lang.org>2018-08-07 13:14:37 +0000
commit39e95165323f76042dfab65772a8411dd85fe088 (patch)
treefa86b133eeb4f43d7a7b741578332bd117607c0d /src/liballoc_system
parent18925dee25ce649562d203e72068e3a57b60b153 (diff)
parent4b731a908b3df2a926eae5fb5233dbc73b098276 (diff)
downloadrust-39e95165323f76042dfab65772a8411dd85fe088.tar.gz
rust-39e95165323f76042dfab65772a8411dd85fe088.zip
Auto merge of #51990 - oli-obk:unstable_union, r=nikomatsakis
Place unions, pointer casts and pointer derefs behind extra feature gates

To ensure we don't stabilize these things together with const fn stabilization (or any other stabilization)

This PR moves union field accesses inside `const fn` behind a feature gate. It was possible without a feature gate before, but since `const fn` was behind a feature gate we can do this change.

While "dereferencing raw pointers" and "casting raw pointers to usize" were hard errors before this PR, one could work around them by abusing unions:

```rust
// deref
union Foo<T> {
    x: &'static T,
    y: *const T,
}
const FOO: u32 = unsafe { *Foo { y: 42 as *const T }.x };

// as usize cast
union Bar<T> {
    x: usize,
    y: *const T,
}
const BAR: usize = unsafe { Bar { y: &1u8 }.x };
```

r? @eddyb

cc @nikomatsakis
Diffstat (limited to 'src/liballoc_system')
0 files changed, 0 insertions, 0 deletions