about summary refs log tree commit diff
path: root/library/core/src/task
diff options
context:
space:
mode:
authorJames Higgins <james.isaac.higgins@gmail.com>2022-04-12 13:54:36 -0300
committerDavid Tolnay <dtolnay@gmail.com>2023-01-02 10:20:59 -0800
commitfd59b628ea4d89099ae8ecfce01f271b2a1d9bf5 (patch)
tree43eec436f214ab049d14cf73c58e348b2e67bae8 /library/core/src/task
parentfb9dfa8ceffb985105be3176d7ed2f99515ea377 (diff)
downloadrust-fd59b628ea4d89099ae8ecfce01f271b2a1d9bf5.tar.gz
rust-fd59b628ea4d89099ae8ecfce01f271b2a1d9bf5.zip
Add PhantomData marker to Context to make Context !Send and !Sync
Diffstat (limited to 'library/core/src/task')
-rw-r--r--library/core/src/task/wake.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/library/core/src/task/wake.rs b/library/core/src/task/wake.rs
index 1b7578376b4..a4425fd234a 100644
--- a/library/core/src/task/wake.rs
+++ b/library/core/src/task/wake.rs
@@ -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.