1 #![feature(rustc_attrs, const_let, const_fn)]
3 #[rustc_layout_scalar_valid_range_start(1)]
5 pub(crate) struct NonZero<T>(pub(crate) T);
8 const fn foo() -> NonZero<u32> {
9 let mut x = unsafe { NonZero(1) };
10 x.0 = 0; //~ ERROR statements in constant functions are unstable
11 //~^ ERROR mutation of layout constrained field is unsafe
15 const fn bar() -> NonZero<u32> {
16 let mut x = unsafe { NonZero(1) };
17 unsafe { x.0 = 0 }; //~ ERROR statements in constant functions are unstable