Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
9a07087b
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,发现更多精彩内容 >>
提交
9a07087b
编写于
1月 30, 2016
作者:
B
bors
浏览文件
操作
浏览文件
下载
差异文件
Auto merge of #31288 - GuillaumeGomez:error_code_tidy, r=brson
r? @steveklabnik
上级
14f33a59
c78bf9d9
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
56 addition
and
9 deletion
+56
-9
src/etc/errorck.py
src/etc/errorck.py
+50
-3
src/librustc/diagnostics.rs
src/librustc/diagnostics.rs
+4
-4
src/librustc_resolve/diagnostics.rs
src/librustc_resolve/diagnostics.rs
+2
-2
未找到文件。
src/etc/errorck.py
浏览文件 @
9a07087b
...
...
@@ -21,8 +21,31 @@ if len(sys.argv) < 2:
src_dir
=
sys
.
argv
[
1
]
errcode_map
=
{}
errcode_checked
=
[]
errcode_not_found
=
[]
error_re
=
re
.
compile
(
"(E\d\d\d\d)"
)
def
check_unused_error_codes
(
error_codes
,
check_error_codes
,
filenames
,
dirnames
,
dirpath
):
for
filename
in
filenames
:
if
filename
==
"diagnostics.rs"
or
not
filename
.
endswith
(
".rs"
):
continue
path
=
os
.
path
.
join
(
dirpath
,
filename
)
with
open
(
path
,
'r'
)
as
f
:
for
line
in
f
:
match
=
error_re
.
search
(
line
)
if
match
:
errcode
=
match
.
group
(
1
)
if
errcode
in
error_codes
:
error_codes
.
remove
(
errcode
)
if
errcode
not
in
check_error_codes
:
check_error_codes
.
append
(
errcode
)
for
dirname
in
dirnames
:
path
=
os
.
path
.
join
(
dirpath
,
dirname
)
for
(
dirpath
,
dnames
,
fnames
)
in
os
.
walk
(
path
):
check_unused_error_codes
(
error_codes
,
check_error_codes
,
fnames
,
dnames
,
dirpath
)
# In the register_long_diagnostics! macro, entries look like this:
#
# EXXXX: r##"
...
...
@@ -35,19 +58,23 @@ error_re = re.compile("(E\d\d\d\d)")
long_diag_begin
=
"r##
\"
"
long_diag_end
=
"
\"
##"
errors
=
False
all_errors
=
[]
for
(
dirpath
,
dirnames
,
filenames
)
in
os
.
walk
(
src_dir
):
if
"src/test"
in
dirpath
or
"src/llvm"
in
dirpath
:
# Short circuit for fast
continue
errcode_to_check
=
[]
for
filename
in
filenames
:
if
filename
!=
"diagnostics.rs"
:
continue
path
=
os
.
path
.
join
(
dirpath
,
filename
)
with
open
(
path
,
'r'
)
as
f
:
inside_long_diag
=
False
errcode_to_check
=
[]
for
line_num
,
line
in
enumerate
(
f
,
start
=
1
):
if
inside_long_diag
:
# Skip duplicate error code checking for this line
...
...
@@ -65,16 +92,36 @@ for (dirpath, dirnames, filenames) in os.walk(src_dir):
errcode_map
[
errcode
]
=
existing
+
new_record
else
:
errcode_map
[
errcode
]
=
new_record
# we don't check if this is a long error explanation
if
(
long_diag_begin
not
in
line
and
not
line
.
strip
().
startswith
(
"//"
)
and
errcode
not
in
errcode_to_check
and
errcode
not
in
errcode_checked
and
errcode
not
in
errcode_not_found
):
errcode_to_check
.
append
(
errcode
)
if
long_diag_begin
in
line
:
inside_long_diag
=
True
break
check_unused_error_codes
(
errcode_to_check
,
errcode_checked
,
filenames
,
dirnames
,
dirpath
)
if
len
(
errcode_to_check
)
>
0
:
for
errcode
in
errcode_to_check
:
if
errcode
in
errcode_checked
:
continue
errcode_not_found
.
append
(
errcode
)
if
len
(
errcode_not_found
)
>
0
:
errcode_not_found
.
sort
()
for
errcode
in
errcode_not_found
:
if
errcode
in
errcode_checked
:
continue
all_errors
.
append
(
errcode
)
print
(
"error: unused error code: "
+
errcode
)
errors
=
True
errors
=
False
all_errors
=
[]
for
errcode
,
entries
in
errcode_map
.
items
():
all_errors
.
append
(
entries
[
0
][
0
])
if
len
(
entries
)
>
1
:
entries
.
sort
()
print
(
"error: duplicate error code "
+
errcode
)
for
entry
in
entries
:
print
(
"{1}: {2}
\n
{3}"
.
format
(
*
entry
))
...
...
src/librustc/diagnostics.rs
浏览文件 @
9a07087b
...
...
@@ -226,7 +226,7 @@ struct X { x: (), }
```
"##
,
E0038
:
r##
##
"
E0038
:
r##"
Trait objects like `Box<Trait>` can only be constructed when certain
requirements are satisfied by the trait in question.
...
...
@@ -478,7 +478,7 @@ trait Super<A> {
There's no easy fix for this, generally code will need to be refactored so that
you no longer need to derive from `Super<Self>`.
"##
##
,
"##
,
E0072
:
r##"
When defining a recursive struct or enum, any use of the type being defined
...
...
@@ -1801,14 +1801,14 @@ impl Foo {
register_diagnostics!
{
//
E0006 // merged with E0005
//
E0006 // merged with E0005
// E0134,
// E0135,
E0278
,
// requirement is not satisfied
E0279
,
// requirement is not satisfied
E0280
,
// requirement is not satisfied
E0284
,
// cannot resolve type
E0285
,
// overflow evaluation builtin bounds
//
E0285, // overflow evaluation builtin bounds
E0298
,
// mismatched types between arms
E0299
,
// mismatched types between arms
// E0300, // unexpanded macro
...
...
src/librustc_resolve/diagnostics.rs
浏览文件 @
9a07087b
...
...
@@ -1046,8 +1046,8 @@ impl Foo for i32 {}
// E0153, unused error code
// E0157, unused error code
E0254
,
// import conflicts with imported crate in this module
E0257
,
E0258
,
//
E0257,
//
E0258,
E0402
,
// cannot use an outer type parameter in this context
E0406
,
// undeclared associated type
E0408
,
// variable from pattern #1 is not bound in pattern #
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录