Skip to content

Commit

Permalink
Properly fix MSRV not allowing function pointers in GlobalBlock
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed Jan 25, 2024
1 parent b7ccba9 commit 17ad4ab
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions crates/block2/src/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@ const GLOBAL_DESCRIPTOR: BlockDescriptor = BlockDescriptor {
/// [`global_block!`]: crate::global_block
#[repr(C)]
pub struct GlobalBlock<A, R = ()> {
header: BlockHeader,
p: PhantomData<fn(A) -> R>,
// TODO: Make this properly private once we have a higher MSRV
#[doc(hidden)]
pub header: BlockHeader,
#[doc(hidden)]
pub p: PhantomData<fn(A) -> R>,
}

unsafe impl<A, R> Sync for GlobalBlock<A, R>
Expand Down Expand Up @@ -69,13 +72,6 @@ impl<A, R> GlobalBlock<A, R> {
basic: &GLOBAL_DESCRIPTOR,
},
};

/// Use the [`global_block`] macro instead.
#[doc(hidden)]
#[inline]
pub const unsafe fn from_header(header: BlockHeader, p: PhantomData<fn(A) -> R>) -> Self {
Self { header, p }
}
}

impl<A, R> Deref for GlobalBlock<A, R>
Expand Down Expand Up @@ -198,7 +194,10 @@ macro_rules! global_block {
unsafe extern "C" fn(),
>(inner)
});
$crate::GlobalBlock::from_header(header, ::core::marker::PhantomData)
$crate::GlobalBlock {
header,
p: ::core::marker::PhantomData
}
};
};
}
Expand Down

0 comments on commit 17ad4ab

Please sign in to comment.