Rollup merge of #84179 - CDirkx:dont_send_sync, r=m-ou-se
Explicitly implement `!Send` and `!Sync` for `sys::{Args, Env}` Remove the field `_dont_send_or_sync_me: PhantomData<*mut ()>` in favor of an explicit implementation of `!Send` and `!Sync`.
This commit is contained in:
commit
78306f03ef
7 changed files with 30 additions and 27 deletions
|
@ -1,6 +1,5 @@
|
||||||
use crate::ffi::OsString;
|
use crate::ffi::OsString;
|
||||||
use crate::fmt;
|
use crate::fmt;
|
||||||
use crate::marker::PhantomData;
|
|
||||||
use crate::vec;
|
use crate::vec;
|
||||||
|
|
||||||
/// One-time global initialization.
|
/// One-time global initialization.
|
||||||
|
@ -20,7 +19,6 @@ pub fn args() -> Args {
|
||||||
|
|
||||||
pub struct Args {
|
pub struct Args {
|
||||||
iter: vec::IntoIter<OsString>,
|
iter: vec::IntoIter<OsString>,
|
||||||
_dont_send_or_sync_me: PhantomData<*mut ()>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Debug for Args {
|
impl fmt::Debug for Args {
|
||||||
|
@ -29,6 +27,9 @@ impl fmt::Debug for Args {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl !Send for Args {}
|
||||||
|
impl !Sync for Args {}
|
||||||
|
|
||||||
impl Iterator for Args {
|
impl Iterator for Args {
|
||||||
type Item = OsString;
|
type Item = OsString;
|
||||||
fn next(&mut self) -> Option<OsString> {
|
fn next(&mut self) -> Option<OsString> {
|
||||||
|
@ -54,7 +55,6 @@ impl DoubleEndedIterator for Args {
|
||||||
mod imp {
|
mod imp {
|
||||||
use super::Args;
|
use super::Args;
|
||||||
use crate::ffi::{CStr, OsString};
|
use crate::ffi::{CStr, OsString};
|
||||||
use crate::marker::PhantomData;
|
|
||||||
use crate::ptr;
|
use crate::ptr;
|
||||||
use crate::sys_common::os_str_bytes::*;
|
use crate::sys_common::os_str_bytes::*;
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ mod imp {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn args() -> Args {
|
pub fn args() -> Args {
|
||||||
Args { iter: clone().into_iter(), _dont_send_or_sync_me: PhantomData }
|
Args { iter: clone().into_iter() }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clone() -> Vec<OsString> {
|
fn clone() -> Vec<OsString> {
|
||||||
|
|
|
@ -110,9 +110,11 @@ pub fn init_environment(env: *const *const i8) {
|
||||||
|
|
||||||
pub struct Env {
|
pub struct Env {
|
||||||
iter: vec::IntoIter<(OsString, OsString)>,
|
iter: vec::IntoIter<(OsString, OsString)>,
|
||||||
_dont_send_or_sync_me: PhantomData<*mut ()>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl !Send for Env {}
|
||||||
|
impl !Sync for Env {}
|
||||||
|
|
||||||
impl Iterator for Env {
|
impl Iterator for Env {
|
||||||
type Item = (OsString, OsString);
|
type Item = (OsString, OsString);
|
||||||
fn next(&mut self) -> Option<(OsString, OsString)> {
|
fn next(&mut self) -> Option<(OsString, OsString)> {
|
||||||
|
@ -134,7 +136,7 @@ pub fn env() -> Env {
|
||||||
result.push((key.clone(), value.clone()));
|
result.push((key.clone(), value.clone()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return Env { iter: result.into_iter(), _dont_send_or_sync_me: PhantomData };
|
return Env { iter: result.into_iter() };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
|
|
||||||
use crate::ffi::OsString;
|
use crate::ffi::OsString;
|
||||||
use crate::fmt;
|
use crate::fmt;
|
||||||
use crate::marker::PhantomData;
|
|
||||||
use crate::vec;
|
use crate::vec;
|
||||||
|
|
||||||
/// One-time global initialization.
|
/// One-time global initialization.
|
||||||
|
@ -27,9 +26,11 @@ pub fn args() -> Args {
|
||||||
|
|
||||||
pub struct Args {
|
pub struct Args {
|
||||||
iter: vec::IntoIter<OsString>,
|
iter: vec::IntoIter<OsString>,
|
||||||
_dont_send_or_sync_me: PhantomData<*mut ()>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl !Send for Args {}
|
||||||
|
impl !Sync for Args {}
|
||||||
|
|
||||||
impl fmt::Debug for Args {
|
impl fmt::Debug for Args {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
self.iter.as_slice().fmt(f)
|
self.iter.as_slice().fmt(f)
|
||||||
|
@ -77,7 +78,6 @@ impl DoubleEndedIterator for Args {
|
||||||
mod imp {
|
mod imp {
|
||||||
use super::Args;
|
use super::Args;
|
||||||
use crate::ffi::{CStr, OsString};
|
use crate::ffi::{CStr, OsString};
|
||||||
use crate::marker::PhantomData;
|
|
||||||
use crate::os::unix::prelude::*;
|
use crate::os::unix::prelude::*;
|
||||||
use crate::ptr;
|
use crate::ptr;
|
||||||
use crate::sync::atomic::{AtomicIsize, AtomicPtr, Ordering};
|
use crate::sync::atomic::{AtomicIsize, AtomicPtr, Ordering};
|
||||||
|
@ -134,7 +134,7 @@ mod imp {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn args() -> Args {
|
pub fn args() -> Args {
|
||||||
Args { iter: clone().into_iter(), _dont_send_or_sync_me: PhantomData }
|
Args { iter: clone().into_iter() }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clone() -> Vec<OsString> {
|
fn clone() -> Vec<OsString> {
|
||||||
|
@ -156,7 +156,6 @@ mod imp {
|
||||||
mod imp {
|
mod imp {
|
||||||
use super::Args;
|
use super::Args;
|
||||||
use crate::ffi::CStr;
|
use crate::ffi::CStr;
|
||||||
use crate::marker::PhantomData;
|
|
||||||
|
|
||||||
pub unsafe fn init(_argc: isize, _argv: *const *const u8) {}
|
pub unsafe fn init(_argc: isize, _argv: *const *const u8) {}
|
||||||
|
|
||||||
|
@ -181,7 +180,7 @@ mod imp {
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
};
|
};
|
||||||
Args { iter: vec.into_iter(), _dont_send_or_sync_me: PhantomData }
|
Args { iter: vec.into_iter() }
|
||||||
}
|
}
|
||||||
|
|
||||||
// As _NSGetArgc and _NSGetArgv aren't mentioned in iOS docs
|
// As _NSGetArgc and _NSGetArgv aren't mentioned in iOS docs
|
||||||
|
@ -248,6 +247,6 @@ mod imp {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Args { iter: res.into_iter(), _dont_send_or_sync_me: PhantomData }
|
Args { iter: res.into_iter() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,6 @@ use crate::ffi::{CStr, CString, OsStr, OsString};
|
||||||
use crate::fmt;
|
use crate::fmt;
|
||||||
use crate::io;
|
use crate::io;
|
||||||
use crate::iter;
|
use crate::iter;
|
||||||
use crate::marker::PhantomData;
|
|
||||||
use crate::mem;
|
use crate::mem;
|
||||||
use crate::memchr;
|
use crate::memchr;
|
||||||
use crate::path::{self, PathBuf};
|
use crate::path::{self, PathBuf};
|
||||||
|
@ -460,9 +459,11 @@ pub fn current_exe() -> io::Result<PathBuf> {
|
||||||
|
|
||||||
pub struct Env {
|
pub struct Env {
|
||||||
iter: vec::IntoIter<(OsString, OsString)>,
|
iter: vec::IntoIter<(OsString, OsString)>,
|
||||||
_dont_send_or_sync_me: PhantomData<*mut ()>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl !Send for Env {}
|
||||||
|
impl !Sync for Env {}
|
||||||
|
|
||||||
impl Iterator for Env {
|
impl Iterator for Env {
|
||||||
type Item = (OsString, OsString);
|
type Item = (OsString, OsString);
|
||||||
fn next(&mut self) -> Option<(OsString, OsString)> {
|
fn next(&mut self) -> Option<(OsString, OsString)> {
|
||||||
|
@ -510,7 +511,7 @@ pub fn env() -> Env {
|
||||||
environ = environ.add(1);
|
environ = environ.add(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Env { iter: result.into_iter(), _dont_send_or_sync_me: PhantomData };
|
return Env { iter: result.into_iter() };
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse(input: &[u8]) -> Option<(OsString, OsString)> {
|
fn parse(input: &[u8]) -> Option<(OsString, OsString)> {
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
use crate::ffi::{CStr, OsStr, OsString};
|
use crate::ffi::{CStr, OsStr, OsString};
|
||||||
use crate::fmt;
|
use crate::fmt;
|
||||||
use crate::marker::PhantomData;
|
|
||||||
use crate::os::wasi::ffi::OsStrExt;
|
use crate::os::wasi::ffi::OsStrExt;
|
||||||
use crate::vec;
|
use crate::vec;
|
||||||
|
|
||||||
|
@ -12,15 +11,14 @@ pub unsafe fn cleanup() {}
|
||||||
|
|
||||||
pub struct Args {
|
pub struct Args {
|
||||||
iter: vec::IntoIter<OsString>,
|
iter: vec::IntoIter<OsString>,
|
||||||
_dont_send_or_sync_me: PhantomData<*mut ()>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl !Send for Args {}
|
||||||
|
impl !Sync for Args {}
|
||||||
|
|
||||||
/// Returns the command line arguments
|
/// Returns the command line arguments
|
||||||
pub fn args() -> Args {
|
pub fn args() -> Args {
|
||||||
Args {
|
Args { iter: maybe_args().unwrap_or(Vec::new()).into_iter() }
|
||||||
iter: maybe_args().unwrap_or(Vec::new()).into_iter(),
|
|
||||||
_dont_send_or_sync_me: PhantomData,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn maybe_args() -> Option<Vec<OsString>> {
|
fn maybe_args() -> Option<Vec<OsString>> {
|
||||||
|
|
|
@ -129,9 +129,11 @@ pub fn current_exe() -> io::Result<PathBuf> {
|
||||||
}
|
}
|
||||||
pub struct Env {
|
pub struct Env {
|
||||||
iter: vec::IntoIter<(OsString, OsString)>,
|
iter: vec::IntoIter<(OsString, OsString)>,
|
||||||
_dont_send_or_sync_me: PhantomData<*mut ()>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl !Send for Env {}
|
||||||
|
impl !Sync for Env {}
|
||||||
|
|
||||||
impl Iterator for Env {
|
impl Iterator for Env {
|
||||||
type Item = (OsString, OsString);
|
type Item = (OsString, OsString);
|
||||||
fn next(&mut self) -> Option<(OsString, OsString)> {
|
fn next(&mut self) -> Option<(OsString, OsString)> {
|
||||||
|
@ -155,7 +157,7 @@ pub fn env() -> Env {
|
||||||
environ = environ.add(1);
|
environ = environ.add(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Env { iter: result.into_iter(), _dont_send_or_sync_me: PhantomData };
|
return Env { iter: result.into_iter() };
|
||||||
}
|
}
|
||||||
|
|
||||||
// See src/libstd/sys/unix/os.rs, same as that
|
// See src/libstd/sys/unix/os.rs, same as that
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use crate::ffi::OsString;
|
use crate::ffi::OsString;
|
||||||
use crate::fmt;
|
use crate::fmt;
|
||||||
use crate::marker::PhantomData;
|
|
||||||
use crate::vec;
|
use crate::vec;
|
||||||
|
|
||||||
pub unsafe fn init(_argc: isize, _argv: *const *const u8) {
|
pub unsafe fn init(_argc: isize, _argv: *const *const u8) {
|
||||||
|
@ -10,14 +9,16 @@ pub unsafe fn init(_argc: isize, _argv: *const *const u8) {
|
||||||
pub unsafe fn cleanup() {}
|
pub unsafe fn cleanup() {}
|
||||||
|
|
||||||
pub fn args() -> Args {
|
pub fn args() -> Args {
|
||||||
Args { iter: Vec::new().into_iter(), _dont_send_or_sync_me: PhantomData }
|
Args { iter: Vec::new().into_iter() }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Args {
|
pub struct Args {
|
||||||
iter: vec::IntoIter<OsString>,
|
iter: vec::IntoIter<OsString>,
|
||||||
_dont_send_or_sync_me: PhantomData<*mut ()>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl !Send for Args {}
|
||||||
|
impl !Sync for Args {}
|
||||||
|
|
||||||
impl fmt::Debug for Args {
|
impl fmt::Debug for Args {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
self.iter.as_slice().fmt(f)
|
self.iter.as_slice().fmt(f)
|
||||||
|
|
Loading…
Reference in a new issue