diff --git a/README.md b/README.md index a60f288..62e36a3 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ features = ["unstable_const"] Your crate root: (`lib.rs`/`main.rs`) ```rust,ignore -#![feature(ptr_offset_from, const_ptr_offset_from, const_maybe_uninit_as_ptr, const_raw_ptr_deref)] +#![feature(const_ptr_offset_from, const_maybe_uninit_as_ptr, const_raw_ptr_deref, const_refs_to_cell)] ``` If you intend to use `offset_of!` inside a `const fn`, also add the `const_fn` compiler feature. diff --git a/src/lib.rs b/src/lib.rs index 454759e..67de5e4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -60,11 +60,10 @@ #![cfg_attr( feature = "unstable_const", feature( - ptr_offset_from, - const_fn, const_ptr_offset_from, const_maybe_uninit_as_ptr, const_raw_ptr_deref, + const_refs_to_cell, ) )] diff --git a/src/offset_of.rs b/src/offset_of.rs index a363d30..d376498 100644 --- a/src/offset_of.rs +++ b/src/offset_of.rs @@ -253,6 +253,18 @@ mod tests { assert_eq!([0; offset_of!(Foo, b)].len(), 4); } + #[cfg(feature = "unstable_const")] + #[test] + fn const_offset_interior_mutable() { + #[repr(C)] + struct Foo { + a: u32, + b: core::cell::Cell, + } + + assert_eq!([0; offset_of!(Foo, b)].len(), 4); + } + #[cfg(feature = "unstable_const")] #[test] fn const_fn_offset() {