Add PhantomData marker to Context to make Context !Send and !Sync

This commit is contained in:
James Higgins 2022-04-12 13:54:36 -03:00 committed by David Tolnay
parent fb9dfa8cef
commit fd59b628ea
No known key found for this signature in database
GPG key ID: F9BA143B95FF6D82

View file

@ -181,6 +181,9 @@ pub struct Context<'a> {
// are contravariant while return-position lifetimes are
// covariant).
_marker: PhantomData<fn(&'a ()) -> &'a ()>,
// Ensure `Context` is `!Send` and `!Sync` in order to allow
// for future `!Send` and / or `!Sync` fields.
_marker2: PhantomData<*mut ()>,
}
impl<'a> Context<'a> {
@ -190,7 +193,7 @@ impl<'a> Context<'a> {
#[must_use]
#[inline]
pub const fn from_waker(waker: &'a Waker) -> Self {
Context { waker, _marker: PhantomData }
Context { waker, _marker: PhantomData, _marker2: PhantomData }
}
/// Returns a reference to the [`Waker`] for the current task.