-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Utilize PhantomData
to enforce !Sync
and !Send
field.
#35426
Conversation
cc @alexcrichton, a nice optimisation. Some backward compat hazard if anybody does transmute out of these, but I don’t think that would ever be problematic. |
@bors: r+ 404e31b4e7f07031843bdfdba4d09e0b18eb1085 Looks good to me, thanks! |
⌛ Testing commit 404e31b with merge 78cdb1e... |
💔 Test failed - auto-linux-64-cross-freebsd |
Compile errors fixed in the latest force push. diff --git a/src/libstd/sys/unix/os.rs b/src/libstd/sys/unix/os.rs
index bc4c22a..6b8dfa5 100644
--- a/src/libstd/sys/unix/os.rs
+++ b/src/libstd/sys/unix/os.rs
@@ -400,7 +400,7 @@ pub fn args() -> Args {
}
}
- Args { iter: res.into_iter(), _dont_send_or_sync_me: ptr::null_mut() }
+ Args { iter: res.into_iter(), _dont_send_or_sync_me: PhantomData }
}
#[cfg(any(target_os = "linux",
@@ -419,7 +419,7 @@ pub fn args() -> Args {
let v: Vec<OsString> = bytes.into_iter().map(|v| {
OsStringExt::from_vec(v)
}).collect();
- Args { iter: v.into_iter(), _dont_send_or_sync_me: ptr::null_mut() }
+ Args { iter: v.into_iter(), _dont_send_or_sync_me: PhantomData }
}
pub struct Env { |
404e31b
to
28218be
Compare
⌛ Testing commit 28218be with merge f013914... |
Utilize `PhantomData` to enforce `!Sync` and `!Send` field. None
Out of curiosity, is there a reason that the following doesn't work? struct Args {
iter: vec::IntoIter<OsString>,
}
struct Env {
iter: vec::IntoIter<(OsString, OsString)>,
}
impl !Send for Args {}
impl !Sync for Args {}
impl !Send for Env {}
impl !Sync for Env {} It ends up giving a better error message when you try to use these types in a |
@apasel422 yeah I think that'd work but |
No description provided.