Skip to content

Utilize PhantomData to enforce !Sync and !Send field. #35426

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

Merged
merged 1 commit into from
Aug 9, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/libstd/sys/unix/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use fmt;
use io;
use iter;
use libc::{self, c_int, c_char, c_void};
use marker::PhantomData;
use mem;
use memchr;
use path::{self, PathBuf};
Expand Down Expand Up @@ -304,7 +305,7 @@ pub fn current_exe() -> io::Result<PathBuf> {

pub struct Args {
iter: vec::IntoIter<OsString>,
_dont_send_or_sync_me: *mut (),
_dont_send_or_sync_me: PhantomData<*mut ()>,
}

impl Iterator for Args {
Expand Down Expand Up @@ -342,7 +343,7 @@ pub fn args() -> Args {
};
Args {
iter: vec.into_iter(),
_dont_send_or_sync_me: ptr::null_mut(),
_dont_send_or_sync_me: PhantomData,
}
}

Expand Down Expand Up @@ -399,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",
Expand All @@ -418,12 +419,12 @@ 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 {
iter: vec::IntoIter<(OsString, OsString)>,
_dont_send_or_sync_me: *mut (),
_dont_send_or_sync_me: PhantomData<*mut ()>,
}

impl Iterator for Env {
Expand Down Expand Up @@ -464,7 +465,7 @@ pub fn env() -> Env {
}
let ret = Env {
iter: result.into_iter(),
_dont_send_or_sync_me: ptr::null_mut(),
_dont_send_or_sync_me: PhantomData,
};
ENV_LOCK.unlock();
return ret
Expand Down