let slot = if pinned {
quote! {
// SAFETY:
- // - `&raw mut (*slot).#ident` points to the `#ident` field of `slot`.
- // - `&raw mut (*slot).#ident` is valid.
+ // - `slot` is valid and properly aligned.
// - `make_field_check` checks that `&raw mut (*slot).#ident` is properly aligned.
// - `make_field_check` prevents `#ident` from being used twice, therefore
// `(*slot).#ident` is exclusively accessed and has not been initialized.
- (unsafe { #data.#ident(&raw mut (*#slot).#ident) })
+ (unsafe { #data.#ident(#slot) })
}
} else {
quote! {
quote! {
/// # Safety
///
- /// - `slot` points to a `#field_name` field of a pinned struct that this
- /// `__ThePinData` describes.
- /// - `slot` is a valid, properly aligned and points to uninitialized and
- /// exclusively accessed memory.
+ /// - `slot` is valid and properly aligned.
+ /// - `(*slot).#field_name` is properly aligned.
+ /// - `(*slot).#field_name` points to uninitialized and exclusively accessed
+ /// memory.
#(#attrs)*
#[inline(always)]
#vis unsafe fn #field_name(
self,
- slot: *mut #ty,
+ slot: *mut #struct_name #ty_generics,
) -> ::pin_init::__internal::Slot<::pin_init::__internal::#pin_marker, #ty> {
// SAFETY:
// - If `#pin_marker` is `Pinned`, the corresponding field is structurally
// pinned.
// - Other safety requirements follows the safety requirement.
- unsafe { ::pin_init::__internal::Slot::new(slot) }
+ unsafe { ::pin_init::__internal::Slot::new(&raw mut (*slot).#field_name) }
}
}
})
macro_rules! assert_pinned {
($ty:ty, $field:ident, $field_ty:ty, inline) => {
// SAFETY: This code is unreachable.
- let _ = move |ptr: *mut $field_ty| unsafe {
+ let _ = move |ptr: *mut $ty| unsafe {
let data = <$ty as $crate::__internal::HasPinData>::__pin_data();
_ = data
.$field(ptr)