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
Showing
想要评论请 注册 或 登录