Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
dc110af7
R
Rust
项目概览
int
/
Rust
接近 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
dc110af7
编写于
4月 14, 2021
作者:
C
Christiaan Dirkx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Explicitly implement `!Send` and `!Sync` for `sys::{Args, Env}`
上级
5f1aeb52
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
30 addition
and
27 deletion
+30
-27
library/std/src/sys/hermit/args.rs
library/std/src/sys/hermit/args.rs
+4
-4
library/std/src/sys/hermit/os.rs
library/std/src/sys/hermit/os.rs
+4
-2
library/std/src/sys/unix/args.rs
library/std/src/sys/unix/args.rs
+6
-7
library/std/src/sys/unix/os.rs
library/std/src/sys/unix/os.rs
+4
-3
library/std/src/sys/wasi/args.rs
library/std/src/sys/wasi/args.rs
+4
-6
library/std/src/sys/wasi/os.rs
library/std/src/sys/wasi/os.rs
+4
-2
library/std/src/sys/wasm/args.rs
library/std/src/sys/wasm/args.rs
+4
-3
未找到文件。
library/std/src/sys/hermit/args.rs
浏览文件 @
dc110af7
use
crate
::
ffi
::
OsString
;
use
crate
::
fmt
;
use
crate
::
marker
::
PhantomData
;
use
crate
::
vec
;
/// One-time global initialization.
...
...
@@ -20,7 +19,6 @@ pub fn args() -> Args {
pub
struct
Args
{
iter
:
vec
::
IntoIter
<
OsString
>
,
_
dont_send_or_sync_me
:
PhantomData
<*
mut
()
>
,
}
impl
fmt
::
Debug
for
Args
{
...
...
@@ -29,6 +27,9 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
}
}
impl
!
Send
for
Args
{}
impl
!
Sync
for
Args
{}
impl
Iterator
for
Args
{
type
Item
=
OsString
;
fn
next
(
&
mut
self
)
->
Option
<
OsString
>
{
...
...
@@ -54,7 +55,6 @@ fn next_back(&mut self) -> Option<OsString> {
mod
imp
{
use
super
::
Args
;
use
crate
::
ffi
::{
CStr
,
OsString
};
use
crate
::
marker
::
PhantomData
;
use
crate
::
ptr
;
use
crate
::
sys_common
::
os_str_bytes
::
*
;
...
...
@@ -77,7 +77,7 @@ pub unsafe fn cleanup() {
}
pub
fn
args
()
->
Args
{
Args
{
iter
:
clone
()
.into_iter
()
,
_
dont_send_or_sync_me
:
PhantomData
}
Args
{
iter
:
clone
()
.into_iter
()
}
}
fn
clone
()
->
Vec
<
OsString
>
{
...
...
library/std/src/sys/hermit/os.rs
浏览文件 @
dc110af7
...
...
@@ -110,9 +110,11 @@ fn parse(input: &[u8]) -> Option<(OsString, OsString)> {
pub
struct
Env
{
iter
:
vec
::
IntoIter
<
(
OsString
,
OsString
)
>
,
_
dont_send_or_sync_me
:
PhantomData
<*
mut
()
>
,
}
impl
!
Send
for
Env
{}
impl
!
Sync
for
Env
{}
impl
Iterator
for
Env
{
type
Item
=
(
OsString
,
OsString
);
fn
next
(
&
mut
self
)
->
Option
<
(
OsString
,
OsString
)
>
{
...
...
@@ -134,7 +136,7 @@ pub fn env() -> Env {
result
.push
((
key
.clone
(),
value
.clone
()));
}
return
Env
{
iter
:
result
.into_iter
()
,
_
dont_send_or_sync_me
:
PhantomData
};
return
Env
{
iter
:
result
.into_iter
()
};
}
}
...
...
library/std/src/sys/unix/args.rs
浏览文件 @
dc110af7
...
...
@@ -7,7 +7,6 @@
use
crate
::
ffi
::
OsString
;
use
crate
::
fmt
;
use
crate
::
marker
::
PhantomData
;
use
crate
::
vec
;
/// One-time global initialization.
...
...
@@ -27,9 +26,11 @@ pub fn args() -> Args {
pub
struct
Args
{
iter
:
vec
::
IntoIter
<
OsString
>
,
_
dont_send_or_sync_me
:
PhantomData
<*
mut
()
>
,
}
impl
!
Send
for
Args
{}
impl
!
Sync
for
Args
{}
impl
fmt
::
Debug
for
Args
{
fn
fmt
(
&
self
,
f
:
&
mut
fmt
::
Formatter
<
'_
>
)
->
fmt
::
Result
{
self
.iter
.as_slice
()
.fmt
(
f
)
...
...
@@ -77,7 +78,6 @@ fn next_back(&mut self) -> Option<OsString> {
mod
imp
{
use
super
::
Args
;
use
crate
::
ffi
::{
CStr
,
OsString
};
use
crate
::
marker
::
PhantomData
;
use
crate
::
os
::
unix
::
prelude
::
*
;
use
crate
::
ptr
;
use
crate
::
sync
::
atomic
::{
AtomicIsize
,
AtomicPtr
,
Ordering
};
...
...
@@ -134,7 +134,7 @@ pub unsafe fn cleanup() {
}
pub
fn
args
()
->
Args
{
Args
{
iter
:
clone
()
.into_iter
()
,
_
dont_send_or_sync_me
:
PhantomData
}
Args
{
iter
:
clone
()
.into_iter
()
}
}
fn
clone
()
->
Vec
<
OsString
>
{
...
...
@@ -156,7 +156,6 @@ fn clone() -> Vec<OsString> {
mod
imp
{
use
super
::
Args
;
use
crate
::
ffi
::
CStr
;
use
crate
::
marker
::
PhantomData
;
pub
unsafe
fn
init
(
_
argc
:
isize
,
_
argv
:
*
const
*
const
u8
)
{}
...
...
@@ -181,7 +180,7 @@ pub fn args() -> Args {
})
.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
...
...
@@ -248,6 +247,6 @@ pub fn args() -> Args {
}
}
Args
{
iter
:
res
.into_iter
()
,
_
dont_send_or_sync_me
:
PhantomData
}
Args
{
iter
:
res
.into_iter
()
}
}
}
library/std/src/sys/unix/os.rs
浏览文件 @
dc110af7
...
...
@@ -12,7 +12,6 @@
use
crate
::
fmt
;
use
crate
::
io
;
use
crate
::
iter
;
use
crate
::
marker
::
PhantomData
;
use
crate
::
mem
;
use
crate
::
memchr
;
use
crate
::
path
::{
self
,
PathBuf
};
...
...
@@ -460,9 +459,11 @@ pub fn current_exe() -> io::Result<PathBuf> {
pub
struct
Env
{
iter
:
vec
::
IntoIter
<
(
OsString
,
OsString
)
>
,
_
dont_send_or_sync_me
:
PhantomData
<*
mut
()
>
,
}
impl
!
Send
for
Env
{}
impl
!
Sync
for
Env
{}
impl
Iterator
for
Env
{
type
Item
=
(
OsString
,
OsString
);
fn
next
(
&
mut
self
)
->
Option
<
(
OsString
,
OsString
)
>
{
...
...
@@ -510,7 +511,7 @@ pub fn env() -> Env {
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
)
>
{
...
...
library/std/src/sys/wasi/args.rs
浏览文件 @
dc110af7
...
...
@@ -2,7 +2,6 @@
use
crate
::
ffi
::{
CStr
,
OsStr
,
OsString
};
use
crate
::
fmt
;
use
crate
::
marker
::
PhantomData
;
use
crate
::
os
::
wasi
::
ffi
::
OsStrExt
;
use
crate
::
vec
;
...
...
@@ -12,15 +11,14 @@ pub unsafe fn cleanup() {}
pub
struct
Args
{
iter
:
vec
::
IntoIter
<
OsString
>
,
_
dont_send_or_sync_me
:
PhantomData
<*
mut
()
>
,
}
impl
!
Send
for
Args
{}
impl
!
Sync
for
Args
{}
/// Returns the command line arguments
pub
fn
args
()
->
Args
{
Args
{
iter
:
maybe_args
()
.unwrap_or
(
Vec
::
new
())
.into_iter
(),
_
dont_send_or_sync_me
:
PhantomData
,
}
Args
{
iter
:
maybe_args
()
.unwrap_or
(
Vec
::
new
())
.into_iter
()
}
}
fn
maybe_args
()
->
Option
<
Vec
<
OsString
>>
{
...
...
library/std/src/sys/wasi/os.rs
浏览文件 @
dc110af7
...
...
@@ -129,9 +129,11 @@ pub fn current_exe() -> io::Result<PathBuf> {
}
pub
struct
Env
{
iter
:
vec
::
IntoIter
<
(
OsString
,
OsString
)
>
,
_
dont_send_or_sync_me
:
PhantomData
<*
mut
()
>
,
}
impl
!
Send
for
Env
{}
impl
!
Sync
for
Env
{}
impl
Iterator
for
Env
{
type
Item
=
(
OsString
,
OsString
);
fn
next
(
&
mut
self
)
->
Option
<
(
OsString
,
OsString
)
>
{
...
...
@@ -155,7 +157,7 @@ pub fn env() -> Env {
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
...
...
library/std/src/sys/wasm/args.rs
浏览文件 @
dc110af7
use
crate
::
ffi
::
OsString
;
use
crate
::
fmt
;
use
crate
::
marker
::
PhantomData
;
use
crate
::
vec
;
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
fn
args
()
->
Args
{
Args
{
iter
:
Vec
::
new
()
.into_iter
()
,
_
dont_send_or_sync_me
:
PhantomData
}
Args
{
iter
:
Vec
::
new
()
.into_iter
()
}
}
pub
struct
Args
{
iter
:
vec
::
IntoIter
<
OsString
>
,
_
dont_send_or_sync_me
:
PhantomData
<*
mut
()
>
,
}
impl
!
Send
for
Args
{}
impl
!
Sync
for
Args
{}
impl
fmt
::
Debug
for
Args
{
fn
fmt
(
&
self
,
f
:
&
mut
fmt
::
Formatter
<
'_
>
)
->
fmt
::
Result
{
self
.iter
.as_slice
()
.fmt
(
f
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录