Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
14982db2
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,发现更多精彩内容 >>
提交
14982db2
编写于
12月 23, 2017
作者:
Z
Zack M. Davis
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
in which the unused-parens lint comes to cover function and method args
Resolves #46137.
上级
44afd767
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
25 addition
and
11 deletion
+25
-11
src/liballoc/vec_deque.rs
src/liballoc/vec_deque.rs
+1
-1
src/librustc_apfloat/ieee.rs
src/librustc_apfloat/ieee.rs
+1
-1
src/librustc_lint/unused.rs
src/librustc_lint/unused.rs
+12
-0
src/librustc_mir/dataflow/impls/borrows.rs
src/librustc_mir/dataflow/impls/borrows.rs
+1
-1
src/librustc_resolve/lib.rs
src/librustc_resolve/lib.rs
+1
-1
src/libstd/sys/unix/thread.rs
src/libstd/sys/unix/thread.rs
+2
-2
src/test/compile-fail/lint-unnecessary-parens.rs
src/test/compile-fail/lint-unnecessary-parens.rs
+7
-5
未找到文件。
src/liballoc/vec_deque.rs
浏览文件 @
14982db2
...
...
@@ -2480,7 +2480,7 @@ fn from(other: VecDeque<T>) -> Self {
if
other
.is_contiguous
()
{
ptr
::
copy
(
buf
.offset
(
tail
as
isize
),
buf
,
len
);
}
else
{
if
(
tail
-
head
)
>=
cmp
::
min
(
(
cap
-
tail
)
,
head
)
{
if
(
tail
-
head
)
>=
cmp
::
min
(
cap
-
tail
,
head
)
{
// There is enough free space in the centre for the shortest block so we can
// do this in at most three copy moves.
if
(
cap
-
tail
)
>
head
{
...
...
src/librustc_apfloat/ieee.rs
浏览文件 @
14982db2
...
...
@@ -1434,7 +1434,7 @@ fn scalbn_r(mut self, exp: ExpInt, round: Round) -> Self {
let
max_change
=
S
::
MAX_EXP
as
i32
-
(
S
::
MIN_EXP
as
i32
-
sig_bits
)
+
1
;
// Clamp to one past the range ends to let normalize handle overflow.
let
exp_change
=
cmp
::
min
(
cmp
::
max
(
exp
as
i32
,
(
-
max_change
-
1
)
),
max_change
);
let
exp_change
=
cmp
::
min
(
cmp
::
max
(
exp
as
i32
,
-
max_change
-
1
),
max_change
);
self
.exp
=
self
.exp
.saturating_add
(
exp_change
as
ExpInt
);
self
=
self
.normalize
(
round
,
Loss
::
ExactlyZero
)
.value
;
if
self
.is_nan
()
{
...
...
src/librustc_lint/unused.rs
浏览文件 @
14982db2
...
...
@@ -302,6 +302,18 @@ fn check_expr(&mut self, cx: &EarlyContext, e: &ast::Expr) {
Assign
(
_
,
ref
value
)
=>
(
value
,
"assigned value"
,
false
),
AssignOp
(
..
,
ref
value
)
=>
(
value
,
"assigned value"
,
false
),
InPlace
(
_
,
ref
value
)
=>
(
value
,
"emplacement value"
,
false
),
Call
(
_
,
ref
args
)
=>
{
for
arg
in
args
{
self
.check_unused_parens_core
(
cx
,
arg
,
"function argument"
,
false
)
}
return
;
},
MethodCall
(
_
,
ref
args
)
=>
{
for
arg
in
&
args
[
1
..
]
{
// first "argument" is self (which sometimes needs parens)
self
.check_unused_parens_core
(
cx
,
arg
,
"method argument"
,
false
)
}
return
;
}
_
=>
return
,
};
self
.check_unused_parens_core
(
cx
,
&
value
,
msg
,
struct_lit_needs_parens
);
...
...
src/librustc_mir/dataflow/impls/borrows.rs
浏览文件 @
14982db2
...
...
@@ -131,7 +131,7 @@ fn fmt(&self, w: &mut fmt::Formatter) -> fmt::Result {
}
impl
ReserveOrActivateIndex
{
fn
reserved
(
i
:
BorrowIndex
)
->
Self
{
ReserveOrActivateIndex
::
new
(
(
i
.index
()
*
2
)
)
}
fn
reserved
(
i
:
BorrowIndex
)
->
Self
{
ReserveOrActivateIndex
::
new
(
i
.index
()
*
2
)
}
fn
active
(
i
:
BorrowIndex
)
->
Self
{
ReserveOrActivateIndex
::
new
((
i
.index
()
*
2
)
+
1
)
}
pub
(
crate
)
fn
is_reservation
(
self
)
->
bool
{
self
.index
()
%
2
==
0
}
...
...
src/librustc_resolve/lib.rs
浏览文件 @
14982db2
...
...
@@ -963,7 +963,7 @@ fn new(parent: Option<Module<'a>>,
unresolved_invocations
:
RefCell
::
new
(
FxHashSet
()),
no_implicit_prelude
:
false
,
glob_importers
:
RefCell
::
new
(
Vec
::
new
()),
globs
:
RefCell
::
new
(
(
Vec
::
new
()
)),
globs
:
RefCell
::
new
(
Vec
::
new
(
)),
traits
:
RefCell
::
new
(
None
),
populated
:
Cell
::
new
(
normal_ancestor_id
.is_local
()),
span
,
...
...
src/libstd/sys/unix/thread.rs
浏览文件 @
14982db2
...
...
@@ -311,8 +311,8 @@ pub unsafe fn current() -> Option<usize> {
#[cfg(target_os
=
"macos"
)]
pub
unsafe
fn
current
()
->
Option
<
usize
>
{
Some
(
(
libc
::
pthread_get_stackaddr_np
(
libc
::
pthread_self
())
as
usize
-
libc
::
pthread_get_stacksize_np
(
libc
::
pthread_self
()
)))
Some
(
libc
::
pthread_get_stackaddr_np
(
libc
::
pthread_self
())
as
usize
-
libc
::
pthread_get_stacksize_np
(
libc
::
pthread_self
(
)))
}
#[cfg(any(target_os
=
"openbsd"
,
target_os
=
"bitrig"
))]
...
...
src/test/compile-fail/lint-unnecessary-parens.rs
浏览文件 @
14982db2
...
...
@@ -13,19 +13,19 @@
#[derive(Eq,
PartialEq)]
struct
X
{
y
:
bool
}
impl
X
{
fn
foo
(
&
self
)
->
bool
{
self
.y
}
fn
foo
(
&
self
,
conjunct
:
bool
)
->
bool
{
self
.y
&&
conjunct
}
}
fn
foo
()
->
isize
{
return
(
1
);
//~ ERROR unnecessary parentheses around `return` value
}
fn
bar
()
->
X
{
return
(
X
{
y
:
true
});
//~ ERROR unnecessary parentheses around `return` value
fn
bar
(
y
:
bool
)
->
X
{
return
(
X
{
y
});
//~ ERROR unnecessary parentheses around `return` value
}
fn
main
()
{
foo
();
bar
(
);
bar
(
(
true
));
//~ ERROR unnecessary parentheses around function argument
if
(
true
)
{}
//~ ERROR unnecessary parentheses around `if` condition
while
(
true
)
{}
//~ ERROR unnecessary parentheses around `while` condition
...
...
@@ -40,13 +40,15 @@ fn main() {
if
(
X
{
y
:
true
}
==
v
)
{}
if
(
X
{
y
:
false
}
.y
)
{}
while
(
X
{
y
:
false
}
.foo
())
{}
while
(
X
{
y
:
false
}
.foo
(
true
))
{}
while
(
true
|
X
{
y
:
false
}
.y
)
{}
match
(
X
{
y
:
false
})
{
_
=>
{}
}
X
{
y
:
false
}
.foo
((
true
));
//~ ERROR unnecessary parentheses around method argument
let
mut
_
a
=
(
0
);
//~ ERROR unnecessary parentheses around assigned value
_
a
=
(
0
);
//~ ERROR unnecessary parentheses around assigned value
_
a
+=
(
1
);
//~ ERROR unnecessary parentheses around assigned value
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录