Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
dd8f0722
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,发现更多精彩内容 >>
提交
dd8f0722
编写于
1月 02, 2020
作者:
L
Lzu Tao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use drop instead of the toilet closure `|_| ()`
上级
50951015
变更
25
隐藏空白更改
内联
并排
Showing
25 changed file
with
35 addition
and
35 deletion
+35
-35
src/liballoc/tests/arc.rs
src/liballoc/tests/arc.rs
+1
-1
src/liballoc/tests/rc.rs
src/liballoc/tests/rc.rs
+1
-1
src/librustc_parse/parser/diagnostics.rs
src/librustc_parse/parser/diagnostics.rs
+2
-2
src/libstd/io/buffered.rs
src/libstd/io/buffered.rs
+1
-1
src/libstd/sys/unix/android.rs
src/libstd/sys/unix/android.rs
+3
-3
src/libstd/sys/unix/fs.rs
src/libstd/sys/unix/fs.rs
+1
-1
src/libstd/sys/unix/net.rs
src/libstd/sys/unix/net.rs
+1
-1
src/libstd/sys/unix/os.rs
src/libstd/sys/unix/os.rs
+2
-2
src/libstd/sys/unix/pipe.rs
src/libstd/sys/unix/pipe.rs
+2
-2
src/libstd/sys/unix/process/process_unix.rs
src/libstd/sys/unix/process/process_unix.rs
+1
-1
src/libstd/sys/vxworks/fs.rs
src/libstd/sys/vxworks/fs.rs
+1
-1
src/libstd/sys/vxworks/net.rs
src/libstd/sys/vxworks/net.rs
+1
-1
src/libstd/sys/vxworks/os.rs
src/libstd/sys/vxworks/os.rs
+2
-2
src/libstd/sys/vxworks/pipe.rs
src/libstd/sys/vxworks/pipe.rs
+2
-2
src/libstd/sys/vxworks/process/process_vxworks.rs
src/libstd/sys/vxworks/process/process_vxworks.rs
+1
-1
src/libstd/sys/wasi/os.rs
src/libstd/sys/wasi/os.rs
+2
-2
src/libstd/sys/windows/fs.rs
src/libstd/sys/windows/fs.rs
+1
-1
src/libstd/sys/windows/handle.rs
src/libstd/sys/windows/handle.rs
+1
-1
src/libstd/sys/windows/net.rs
src/libstd/sys/windows/net.rs
+1
-1
src/libstd/sys/windows/os.rs
src/libstd/sys/windows/os.rs
+3
-3
src/libstd/sys_common/mod.rs
src/libstd/sys_common/mod.rs
+1
-1
src/libstd/sys_common/net.rs
src/libstd/sys_common/net.rs
+1
-1
src/test/ui/async-await/issues/issue-64433.rs
src/test/ui/async-await/issues/issue-64433.rs
+1
-1
src/test/ui/nll/issue-50343.rs
src/test/ui/nll/issue-50343.rs
+1
-1
src/test/ui/paths-containing-nul.rs
src/test/ui/paths-containing-nul.rs
+1
-1
未找到文件。
src/liballoc/tests/arc.rs
浏览文件 @
dd8f0722
...
...
@@ -142,7 +142,7 @@ fn shared_from_iter_trustedlen_normal() {
// Try a ZST to make sure it is handled well.
{
let
iter
=
(
0
..
SHARED_ITER_MAX
)
.map
(
|
_
|
()
);
let
iter
=
(
0
..
SHARED_ITER_MAX
)
.map
(
drop
);
let
vec
=
iter
.clone
()
.collect
::
<
Vec
<
_
>>
();
let
rc
=
iter
.collect
::
<
Rc
<
[
_
]
>>
();
assert_eq!
(
&*
vec
,
&*
rc
);
...
...
src/liballoc/tests/rc.rs
浏览文件 @
dd8f0722
...
...
@@ -138,7 +138,7 @@ fn shared_from_iter_trustedlen_normal() {
// Try a ZST to make sure it is handled well.
{
let
iter
=
(
0
..
SHARED_ITER_MAX
)
.map
(
|
_
|
()
);
let
iter
=
(
0
..
SHARED_ITER_MAX
)
.map
(
drop
);
let
vec
=
iter
.clone
()
.collect
::
<
Vec
<
_
>>
();
let
rc
=
iter
.collect
::
<
Rc
<
[
_
]
>>
();
assert_eq!
(
&*
vec
,
&*
rc
);
...
...
src/librustc_parse/parser/diagnostics.rs
浏览文件 @
dd8f0722
...
...
@@ -866,7 +866,7 @@ pub(super) fn expect_semi(&mut self) -> PResult<'a, ()> {
let
appl
=
Applicability
::
MachineApplicable
;
if
self
.token.span
==
DUMMY_SP
||
self
.prev_span
==
DUMMY_SP
{
// Likely inside a macro, can't provide meaninful suggestions.
return
self
.expect
(
&
token
::
Semi
)
.map
(
|
_
|
()
);
return
self
.expect
(
&
token
::
Semi
)
.map
(
drop
);
}
else
if
!
sm
.is_multiline
(
self
.prev_span
.until
(
self
.token.span
))
{
// The current token is in the same line as the prior token, not recoverable.
}
else
if
self
.look_ahead
(
1
,
|
t
|
{
...
...
@@ -905,7 +905,7 @@ pub(super) fn expect_semi(&mut self) -> PResult<'a, ()> {
.emit
();
return
Ok
(());
}
self
.expect
(
&
token
::
Semi
)
.map
(
|
_
|
()
)
// Error unconditionally
self
.expect
(
&
token
::
Semi
)
.map
(
drop
)
// Error unconditionally
}
pub
(
super
)
fn
parse_semi_or_incorrect_foreign_fn_body
(
...
...
src/libstd/io/buffered.rs
浏览文件 @
dd8f0722
...
...
@@ -232,7 +232,7 @@ pub fn seek_relative(&mut self, offset: i64) -> io::Result<()> {
}
}
}
self
.seek
(
SeekFrom
::
Current
(
offset
))
.map
(
|
_
|
()
)
self
.seek
(
SeekFrom
::
Current
(
offset
))
.map
(
drop
)
}
}
...
...
src/libstd/sys/unix/android.rs
浏览文件 @
dd8f0722
...
...
@@ -93,12 +93,12 @@ pub fn ftruncate64(fd: c_int, size: u64) -> io::Result<()> {
unsafe
{
match
ftruncate64
.get
()
{
Some
(
f
)
=>
cvt_r
(||
f
(
fd
,
size
as
i64
))
.map
(
|
_
|
()
),
Some
(
f
)
=>
cvt_r
(||
f
(
fd
,
size
as
i64
))
.map
(
drop
),
None
=>
{
if
size
>
i32
::
max_value
()
as
u64
{
Err
(
io
::
Error
::
new
(
io
::
ErrorKind
::
InvalidInput
,
"cannot truncate >2GB"
))
}
else
{
cvt_r
(||
ftruncate
(
fd
,
size
as
i32
))
.map
(
|
_
|
()
)
cvt_r
(||
ftruncate
(
fd
,
size
as
i32
))
.map
(
drop
)
}
}
}
...
...
@@ -107,7 +107,7 @@ pub fn ftruncate64(fd: c_int, size: u64) -> io::Result<()> {
#[cfg(target_pointer_width
=
"64"
)]
pub
fn
ftruncate64
(
fd
:
c_int
,
size
:
u64
)
->
io
::
Result
<
()
>
{
unsafe
{
cvt_r
(||
ftruncate
(
fd
,
size
as
i64
))
.map
(
|
_
|
()
)
}
unsafe
{
cvt_r
(||
ftruncate
(
fd
,
size
as
i64
))
.map
(
drop
)
}
}
#[cfg(target_pointer_width
=
"32"
)]
...
...
src/libstd/sys/unix/fs.rs
浏览文件 @
dd8f0722
...
...
@@ -814,7 +814,7 @@ pub fn truncate(&self, size: u64) -> io::Result<()> {
use
crate
::
convert
::
TryInto
;
let
size
:
off64_t
=
size
.try_into
()
.map_err
(|
e
|
io
::
Error
::
new
(
io
::
ErrorKind
::
InvalidInput
,
e
))
?
;
cvt_r
(||
unsafe
{
ftruncate64
(
self
.0
.raw
(),
size
)
})
.map
(
|
_
|
()
)
cvt_r
(||
unsafe
{
ftruncate64
(
self
.0
.raw
(),
size
)
})
.map
(
drop
)
}
}
...
...
src/libstd/sys/unix/net.rs
浏览文件 @
dd8f0722
...
...
@@ -324,7 +324,7 @@ pub fn nodelay(&self) -> io::Result<bool> {
pub
fn
set_nonblocking
(
&
self
,
nonblocking
:
bool
)
->
io
::
Result
<
()
>
{
let
mut
nonblocking
=
nonblocking
as
libc
::
c_int
;
cvt
(
unsafe
{
libc
::
ioctl
(
*
self
.as_inner
(),
libc
::
FIONBIO
,
&
mut
nonblocking
)
})
.map
(
|
_
|
()
)
cvt
(
unsafe
{
libc
::
ioctl
(
*
self
.as_inner
(),
libc
::
FIONBIO
,
&
mut
nonblocking
)
})
.map
(
drop
)
}
pub
fn
take_error
(
&
self
)
->
io
::
Result
<
Option
<
io
::
Error
>>
{
...
...
src/libstd/sys/unix/os.rs
浏览文件 @
dd8f0722
...
...
@@ -529,7 +529,7 @@ pub fn setenv(k: &OsStr, v: &OsStr) -> io::Result<()> {
unsafe
{
let
_
guard
=
env_lock
();
cvt
(
libc
::
setenv
(
k
.as_ptr
(),
v
.as_ptr
(),
1
))
.map
(
|
_
|
()
)
cvt
(
libc
::
setenv
(
k
.as_ptr
(),
v
.as_ptr
(),
1
))
.map
(
drop
)
}
}
...
...
@@ -538,7 +538,7 @@ pub fn unsetenv(n: &OsStr) -> io::Result<()> {
unsafe
{
let
_
guard
=
env_lock
();
cvt
(
libc
::
unsetenv
(
nbuf
.as_ptr
()))
.map
(
|
_
|
()
)
cvt
(
libc
::
unsetenv
(
nbuf
.as_ptr
()))
.map
(
drop
)
}
}
...
...
src/libstd/sys/unix/pipe.rs
浏览文件 @
dd8f0722
...
...
@@ -99,11 +99,11 @@ pub fn read2(p1: AnonPipe, v1: &mut Vec<u8>, p2: AnonPipe, v2: &mut Vec<u8>) ->
if
fds
[
0
]
.revents
!=
0
&&
read
(
&
p1
,
v1
)
?
{
p2
.set_nonblocking
(
false
)
?
;
return
p2
.read_to_end
(
v2
)
.map
(
|
_
|
()
);
return
p2
.read_to_end
(
v2
)
.map
(
drop
);
}
if
fds
[
1
]
.revents
!=
0
&&
read
(
&
p2
,
v2
)
?
{
p1
.set_nonblocking
(
false
)
?
;
return
p1
.read_to_end
(
v1
)
.map
(
|
_
|
()
);
return
p1
.read_to_end
(
v1
)
.map
(
drop
);
}
}
...
...
src/libstd/sys/unix/process/process_unix.rs
浏览文件 @
dd8f0722
...
...
@@ -425,7 +425,7 @@ pub fn kill(&mut self) -> io::Result<()> {
"invalid argument: can't kill an exited process"
,
))
}
else
{
cvt
(
unsafe
{
libc
::
kill
(
self
.pid
,
libc
::
SIGKILL
)
})
.map
(
|
_
|
()
)
cvt
(
unsafe
{
libc
::
kill
(
self
.pid
,
libc
::
SIGKILL
)
})
.map
(
drop
)
}
}
...
...
src/libstd/sys/vxworks/fs.rs
浏览文件 @
dd8f0722
...
...
@@ -340,7 +340,7 @@ unsafe fn os_datasync(fd: c_int) -> c_int {
}
pub
fn
truncate
(
&
self
,
size
:
u64
)
->
io
::
Result
<
()
>
{
return
cvt_r
(||
unsafe
{
ftruncate
(
self
.0
.raw
(),
size
as
off_t
)
})
.map
(
|
_
|
()
);
return
cvt_r
(||
unsafe
{
ftruncate
(
self
.0
.raw
(),
size
as
off_t
)
})
.map
(
drop
);
}
pub
fn
read
(
&
self
,
buf
:
&
mut
[
u8
])
->
io
::
Result
<
usize
>
{
...
...
src/libstd/sys/vxworks/net.rs
浏览文件 @
dd8f0722
...
...
@@ -261,7 +261,7 @@ pub fn nodelay(&self) -> io::Result<bool> {
pub
fn
set_nonblocking
(
&
self
,
nonblocking
:
bool
)
->
io
::
Result
<
()
>
{
let
mut
nonblocking
=
nonblocking
as
libc
::
c_int
;
cvt
(
unsafe
{
libc
::
ioctl
(
*
self
.as_inner
(),
libc
::
FIONBIO
,
&
mut
nonblocking
)
})
.map
(
|
_
|
()
)
cvt
(
unsafe
{
libc
::
ioctl
(
*
self
.as_inner
(),
libc
::
FIONBIO
,
&
mut
nonblocking
)
})
.map
(
drop
)
}
pub
fn
take_error
(
&
self
)
->
io
::
Result
<
Option
<
io
::
Error
>>
{
...
...
src/libstd/sys/vxworks/os.rs
浏览文件 @
dd8f0722
...
...
@@ -279,7 +279,7 @@ pub fn setenv(k: &OsStr, v: &OsStr) -> io::Result<()> {
unsafe
{
let
_
guard
=
env_lock
();
cvt
(
libc
::
setenv
(
k
.as_ptr
(),
v
.as_ptr
(),
1
))
.map
(
|
_
|
()
)
cvt
(
libc
::
setenv
(
k
.as_ptr
(),
v
.as_ptr
(),
1
))
.map
(
drop
)
}
}
...
...
@@ -288,7 +288,7 @@ pub fn unsetenv(n: &OsStr) -> io::Result<()> {
unsafe
{
let
_
guard
=
env_lock
();
cvt
(
libc
::
unsetenv
(
nbuf
.as_ptr
()))
.map
(
|
_
|
()
)
cvt
(
libc
::
unsetenv
(
nbuf
.as_ptr
()))
.map
(
drop
)
}
}
...
...
src/libstd/sys/vxworks/pipe.rs
浏览文件 @
dd8f0722
...
...
@@ -66,11 +66,11 @@ pub fn read2(p1: AnonPipe, v1: &mut Vec<u8>, p2: AnonPipe, v2: &mut Vec<u8>) ->
if
fds
[
0
]
.revents
!=
0
&&
read
(
&
p1
,
v1
)
?
{
p2
.set_nonblocking_pipe
(
false
)
?
;
return
p2
.read_to_end
(
v2
)
.map
(
|
_
|
()
);
return
p2
.read_to_end
(
v2
)
.map
(
drop
);
}
if
fds
[
1
]
.revents
!=
0
&&
read
(
&
p2
,
v2
)
?
{
p1
.set_nonblocking_pipe
(
false
)
?
;
return
p1
.read_to_end
(
v1
)
.map
(
|
_
|
()
);
return
p1
.read_to_end
(
v1
)
.map
(
drop
);
}
}
...
...
src/libstd/sys/vxworks/process/process_vxworks.rs
浏览文件 @
dd8f0722
...
...
@@ -138,7 +138,7 @@ pub fn kill(&mut self) -> io::Result<()> {
"invalid argument: can't kill an exited process"
,
))
}
else
{
cvt
(
unsafe
{
libc
::
kill
(
self
.pid
,
libc
::
SIGKILL
)
})
.map
(
|
_
|
()
)
cvt
(
unsafe
{
libc
::
kill
(
self
.pid
,
libc
::
SIGKILL
)
})
.map
(
drop
)
}
}
...
...
src/libstd/sys/wasi/os.rs
浏览文件 @
dd8f0722
...
...
@@ -151,7 +151,7 @@ pub fn setenv(k: &OsStr, v: &OsStr) -> io::Result<()> {
unsafe
{
let
_
guard
=
env_lock
();
cvt
(
libc
::
setenv
(
k
.as_ptr
(),
v
.as_ptr
(),
1
))
.map
(
|
_
|
()
)
cvt
(
libc
::
setenv
(
k
.as_ptr
(),
v
.as_ptr
(),
1
))
.map
(
drop
)
}
}
...
...
@@ -160,7 +160,7 @@ pub fn unsetenv(n: &OsStr) -> io::Result<()> {
unsafe
{
let
_
guard
=
env_lock
();
cvt
(
libc
::
unsetenv
(
nbuf
.as_ptr
()))
.map
(
|
_
|
()
)
cvt
(
libc
::
unsetenv
(
nbuf
.as_ptr
()))
.map
(
drop
)
}
}
...
...
src/libstd/sys/windows/fs.rs
浏览文件 @
dd8f0722
...
...
@@ -923,6 +923,6 @@ fn symlink_junction_inner(target: &Path, junction: &Path) -> io::Result<()> {
&mut ret,
ptr::null_mut(),
))
.map(
|_| ()
)
.map(
drop
)
}
}
src/libstd/sys/windows/handle.rs
浏览文件 @
dd8f0722
...
...
@@ -156,7 +156,7 @@ pub fn overlapped_result(
}
pub
fn
cancel_io
(
&
self
)
->
io
::
Result
<
()
>
{
unsafe
{
cvt
(
c
::
CancelIo
(
self
.raw
()))
.map
(
|
_
|
()
)
}
unsafe
{
cvt
(
c
::
CancelIo
(
self
.raw
()))
.map
(
drop
)
}
}
pub
fn
write
(
&
self
,
buf
:
&
[
u8
])
->
io
::
Result
<
usize
>
{
...
...
src/libstd/sys/windows/net.rs
浏览文件 @
dd8f0722
...
...
@@ -355,7 +355,7 @@ pub fn timeout(&self, kind: c_int) -> io::Result<Option<Duration>> {
#[cfg(not(target_vendor
=
"uwp"
))]
fn
set_no_inherit
(
&
self
)
->
io
::
Result
<
()
>
{
sys
::
cvt
(
unsafe
{
c
::
SetHandleInformation
(
self
.0
as
c
::
HANDLE
,
c
::
HANDLE_FLAG_INHERIT
,
0
)
})
.map
(
|
_
|
()
)
.map
(
drop
)
}
#[cfg(target_vendor
=
"uwp"
)]
...
...
src/libstd/sys/windows/os.rs
浏览文件 @
dd8f0722
...
...
@@ -247,7 +247,7 @@ pub fn chdir(p: &path::Path) -> io::Result<()> {
let
mut
p
=
p
.encode_wide
()
.collect
::
<
Vec
<
_
>>
();
p
.push
(
0
);
cvt
(
unsafe
{
c
::
SetCurrentDirectoryW
(
p
.as_ptr
())
})
.map
(
|
_
|
()
)
cvt
(
unsafe
{
c
::
SetCurrentDirectoryW
(
p
.as_ptr
())
})
.map
(
drop
)
}
pub
fn
getenv
(
k
:
&
OsStr
)
->
io
::
Result
<
Option
<
OsString
>>
{
...
...
@@ -272,12 +272,12 @@ pub fn setenv(k: &OsStr, v: &OsStr) -> io::Result<()> {
let
k
=
to_u16s
(
k
)
?
;
let
v
=
to_u16s
(
v
)
?
;
cvt
(
unsafe
{
c
::
SetEnvironmentVariableW
(
k
.as_ptr
(),
v
.as_ptr
())
})
.map
(
|
_
|
()
)
cvt
(
unsafe
{
c
::
SetEnvironmentVariableW
(
k
.as_ptr
(),
v
.as_ptr
())
})
.map
(
drop
)
}
pub
fn
unsetenv
(
n
:
&
OsStr
)
->
io
::
Result
<
()
>
{
let
v
=
to_u16s
(
n
)
?
;
cvt
(
unsafe
{
c
::
SetEnvironmentVariableW
(
v
.as_ptr
(),
ptr
::
null
())
})
.map
(
|
_
|
()
)
cvt
(
unsafe
{
c
::
SetEnvironmentVariableW
(
v
.as_ptr
(),
ptr
::
null
())
})
.map
(
drop
)
}
pub
fn
temp_dir
()
->
PathBuf
{
...
...
src/libstd/sys_common/mod.rs
浏览文件 @
dd8f0722
...
...
@@ -36,7 +36,7 @@
match
$e
{
$ok
(
v
)
=>
v
,
ref
err
=>
{
let
err
=
err
.as_ref
()
.map
(
|
_
|
()
);
// map Ok/Some which might not be Debug
let
err
=
err
.as_ref
()
.map
(
drop
);
// map Ok/Some which might not be Debug
rtabort!
(
concat!
(
"unwrap failed: "
,
stringify!
(
$e
),
" = {:?}"
),
err
)
}
}
...
...
src/libstd/sys_common/net.rs
浏览文件 @
dd8f0722
...
...
@@ -659,7 +659,7 @@ pub fn send(&self, buf: &[u8]) -> io::Result<usize> {
pub
fn
connect
(
&
self
,
addr
:
io
::
Result
<&
SocketAddr
>
)
->
io
::
Result
<
()
>
{
let
(
addrp
,
len
)
=
addr
?
.into_inner
();
cvt_r
(||
unsafe
{
c
::
connect
(
*
self
.inner
.as_inner
(),
addrp
,
len
)
})
.map
(
|
_
|
()
)
cvt_r
(||
unsafe
{
c
::
connect
(
*
self
.inner
.as_inner
(),
addrp
,
len
)
})
.map
(
drop
)
}
}
...
...
src/test/ui/async-await/issues/issue-64433.rs
浏览文件 @
dd8f0722
...
...
@@ -23,7 +23,7 @@ async fn something_with_a(&mut self, a: A<'_>) -> Result<(), String> {
async
fn
can_error
(
some_string
:
&
str
)
->
Result
<
(),
String
>
{
let
a
=
A
{
inner
:
vec!
[
some_string
,
"foo"
]
};
let
mut
b
=
B
{};
Ok
(
b
.something_with_a
(
a
)
.await
.map
(
|
_
|
()
)
?
)
Ok
(
b
.something_with_a
(
a
)
.await
.map
(
drop
)
?
)
}
fn
main
()
{
...
...
src/test/ui/nll/issue-50343.rs
浏览文件 @
dd8f0722
...
...
@@ -3,6 +3,6 @@
#![deny(unused_mut)]
fn
main
()
{
vec!
[
42
]
.iter
()
.map
(
|
_
|
()
)
.count
();
vec!
[
42
]
.iter
()
.map
(
drop
)
.count
();
vec!
[(
42
,
22
)]
.iter
()
.map
(|(
_
x
,
_
y
)|
())
.count
();
}
src/test/ui/paths-containing-nul.rs
浏览文件 @
dd8f0722
...
...
@@ -17,7 +17,7 @@ fn inner(on: &str, result: io::Result<()>) {
"{} returned a strange {:?} on a path with NUL"
,
on
,
e
.kind
()),
}
}
inner
(
on
,
result
.map
(
|
_
|
()
))
inner
(
on
,
result
.map
(
drop
))
}
fn
main
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录