Skip to content

Commit

Permalink
Auto merge of rust-lang#35426 - frewsxcv:os-sys-env-args-phantoms, r=…
Browse files Browse the repository at this point in the history
…alexcrichton

Utilize `PhantomData` to enforce `!Sync` and `!Send` field.

None
  • Loading branch information
bors authored Aug 9, 2016
2 parents c2b03f8 + 28218be commit f013914
Showing 1 changed file with 7 additions and 6 deletions.
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 @@ -305,7 +306,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 @@ -343,7 +344,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 @@ -400,7 +401,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 @@ -419,12 +420,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 @@ -465,7 +466,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

0 comments on commit f013914

Please sign in to comment.