diff --git a/helper_crates/const-field-offset/src/lib.rs b/helper_crates/const-field-offset/src/lib.rs index 09f53deee..6f49e59d9 100644 --- a/helper_crates/const-field-offset/src/lib.rs +++ b/helper_crates/const-field-offset/src/lib.rs @@ -23,11 +23,23 @@ pub use const_field_offset_macro::FieldOffsets; pub struct FieldOffset( /// Offset in bytes of the field within the struct usize, - // ### Changed from Fn to fn to allow const - // it is fine to be fariant - PhantomData<(*const T, *const U)>, + /// ### Changed from Fn to fn to allow const + /// Should be fn(T)->U, but we can't make that work in const context. + /// So make it invariant in T instead + /// + /// ```compile_fail + /// use const_field_offset::FieldOffset; + /// struct Foo<'a>(&'a str); + /// fn test<'a>(foo: &Foo<'a>, of: FieldOffset, &'static str>) -> &'static str { + /// let of2 : FieldOffset, &'static str> = of; // This must not compile + /// of2.apply(foo) + /// } + /// ``` + PhantomData<(*mut T, *const U)>, ); +unsafe impl Send for FieldOffset {} + impl FieldOffset { // Use MaybeUninit to get a fake T #[cfg(fieldoffset_maybe_uninit)]