Skip to content

Commit

Permalink
Add PhantomData marker to Context to make Context !Send and !Sync
Browse files Browse the repository at this point in the history
  • Loading branch information
jihiggins authored and dtolnay committed Jan 2, 2023
1 parent fb9dfa8 commit fd59b62
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion library/core/src/task/wake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand All @@ -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.
Expand Down

0 comments on commit fd59b62

Please sign in to comment.