1 #![feature(rustc_attrs, const_let, const_fn)]
5 #[rustc_layout_scalar_valid_range_start(1)]
7 pub(crate) struct NonZero<T>(pub(crate) T);
10 const fn foo() -> NonZero<Cell<u32>> {
11 let mut x = unsafe { NonZero(Cell::new(1)) };
12 let y = &x.0; //~ ERROR cannot borrow a constant which may contain interior mutability
13 //~^ ERROR borrow of layout constrained field with interior mutability
14 unsafe { NonZero(Cell::new(1)) }
17 const fn bar() -> NonZero<Cell<u32>> {
18 let mut x = unsafe { NonZero(Cell::new(1)) };
19 let y = unsafe { &x.0 }; //~ ERROR cannot borrow a constant which may contain interior mut
20 unsafe { NonZero(Cell::new(1)) }