Skip to content

Commit fd59b62

Browse files
James Higginsdtolnay
James Higgins
authored andcommitted
Add PhantomData marker to Context to make Context !Send and !Sync
1 parent fb9dfa8 commit fd59b62

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

library/core/src/task/wake.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ pub struct Context<'a> {
181181
// are contravariant while return-position lifetimes are
182182
// covariant).
183183
_marker: PhantomData<fn(&'a ()) -> &'a ()>,
184+
// Ensure `Context` is `!Send` and `!Sync` in order to allow
185+
// for future `!Send` and / or `!Sync` fields.
186+
_marker2: PhantomData<*mut ()>,
184187
}
185188

186189
impl<'a> Context<'a> {
@@ -190,7 +193,7 @@ impl<'a> Context<'a> {
190193
#[must_use]
191194
#[inline]
192195
pub const fn from_waker(waker: &'a Waker) -> Self {
193-
Context { waker, _marker: PhantomData }
196+
Context { waker, _marker: PhantomData, _marker2: PhantomData }
194197
}
195198

196199
/// Returns a reference to the [`Waker`] for the current task.

0 commit comments

Comments
 (0)