Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
7ffb2cb7
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,发现更多精彩内容 >>
提交
7ffb2cb7
编写于
1月 19, 2012
作者:
H
Haitao Li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rustc: Name the lint-style check module `lint`
Issue #1543
上级
327a15d5
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
93 addition
and
71 deletion
+93
-71
man/rustc.1
man/rustc.1
+4
-2
src/comp/driver/driver.rs
src/comp/driver/driver.rs
+10
-7
src/comp/driver/rustc.rs
src/comp/driver/rustc.rs
+1
-1
src/comp/driver/session.rs
src/comp/driver/session.rs
+2
-1
src/comp/middle/check_usage.rs
src/comp/middle/check_usage.rs
+0
-59
src/comp/middle/lint.rs
src/comp/middle/lint.rs
+75
-0
src/comp/rustc.rc
src/comp/rustc.rc
+1
-1
未找到文件。
man/rustc.1
浏览文件 @
7ffb2cb7
...
...
@@ -124,8 +124,10 @@ Build a test harness.
\fB--warn-unused-imports\fR:
Warn about unnecessary imports.
.TP
\fB--no-check-usage\fR:
Disables various one-off usage analyses.
\fB--no-lint-ctypes\fR:
Disables checking of possibly incorrect usage of Rust int or uint types in
native function declarations, where types defined in libcore::ctypes should be
used instead. Ctypes check emits warnings by default.
.SH "BUGS"
See \fBhttps://github.com/mozilla/rust/issues\fR for a list of known bugs.
.SH "AUTHOR"
...
...
src/comp/driver/driver.rs
浏览文件 @
7ffb2cb7
...
...
@@ -6,7 +6,7 @@
import
syntax
::{
ast
,
codemap
};
import
front
::
attr
;
import
middle
::{
trans
,
resolve
,
freevars
,
kind
,
ty
,
typeck
,
fn_usage
,
last_use
,
check_usage
};
last_use
,
lint
};
import
syntax
::
print
::{
pp
,
pprust
};
import
util
::{
ppaux
,
filesearch
};
import
back
::
link
;
...
...
@@ -203,9 +203,9 @@ fn compile_upto(sess: session, cfg: ast::crate_cfg,
bind
last_use
::
find_last_uses
(
crate
,
def_map
,
ref_map
,
ty_cx
));
time
(
time_passes
,
"kind checking"
,
bind
kind
::
check_crate
(
ty_cx
,
method_map
,
last_uses
,
crate
));
if
sess
.opts.check_usage
{
time
(
time_passes
,
"usage analyses"
,
bind
check_usage
::
check_crate
(
ty_cx
,
crate
));
if
vec
::
len
(
sess
.opts.lint_opts
)
>
0u
{
let
timer
=
bind
time
(
time_passes
,
_
,
_
);
lint
::
check_crate
(
ty_cx
,
crate
,
sess
.opts.lint_opts
,
timer
)
}
if
upto
==
cu_no_trans
{
ret
{
crate
:
crate
,
tcx
:
some
(
ty_cx
),
src
:
src
};
}
...
...
@@ -384,6 +384,10 @@ fn build_session_options(match: getopts::match,
let
parse_only
=
opt_present
(
match
,
"parse-only"
);
let
no_trans
=
opt_present
(
match
,
"no-trans"
);
let
lint_opts
:
[
lint
::
option
]
=
[];
if
!
opt_present
(
match
,
"no-lint-ctypes"
)
{
lint_opts
+=
[
lint
::
ctypes
];
}
let
output_type
=
if
parse_only
||
no_trans
{
...
...
@@ -399,7 +403,6 @@ fn build_session_options(match: getopts::match,
}
else
{
link
::
output_type_exe
};
let
libcore
=
!
opt_present
(
match
,
"no-core"
);
let
verify
=
!
opt_present
(
match
,
"no-verify"
);
let
check_usage
=
!
opt_present
(
match
,
"no-usage-check"
);
let
save_temps
=
opt_present
(
match
,
"save-temps"
);
let
extra_debuginfo
=
opt_present
(
match
,
"xg"
);
let
debuginfo
=
opt_present
(
match
,
"g"
)
||
extra_debuginfo
;
...
...
@@ -451,7 +454,7 @@ fn build_session_options(match: getopts::match,
debuginfo
:
debuginfo
,
extra_debuginfo
:
extra_debuginfo
,
verify
:
verify
,
check_usage
:
check_usage
,
lint_opts
:
lint_opts
,
save_temps
:
save_temps
,
stats
:
stats
,
time_passes
:
time_passes
,
...
...
@@ -520,7 +523,7 @@ fn opts() -> [getopts::opt] {
optopt
(
"sysroot"
),
optopt
(
"target"
),
optflag
(
"stats"
),
optflag
(
"time-passes"
),
optflag
(
"time-llvm-passes"
),
optflag
(
"no-verify"
),
optflag
(
"no-
usage-check
"
),
optflag
(
"no-
lint-ctypes
"
),
optmulti
(
"cfg"
),
optflag
(
"test"
),
optflag
(
"no-core"
),
optflag
(
"lib"
),
optflag
(
"bin"
),
optflag
(
"static"
),
optflag
(
"gc"
),
...
...
src/comp/driver/rustc.rs
浏览文件 @
7ffb2cb7
...
...
@@ -38,7 +38,6 @@ fn usage(argv0: str) {
--ls list the symbols defined by a crate file
-L <path> add a directory to the library search path
--no-verify suppress LLVM verification step (slight speedup)
--no-check-usage suppress various one-off usage analyses
--parse-only parse only; do not compile, assemble, or link
--no-trans run all passes except translation; no output
-g produce debug info
...
...
@@ -59,6 +58,7 @@ fn usage(argv0: str) {
--gc garbage collect shared data (experimental/temporary)
--warn-unused-imports
warn about unnecessary imports
--no-lint-ctypes suppress lint-style ctypes usage check
"
);
}
...
...
src/comp/driver/session.rs
浏览文件 @
7ffb2cb7
...
...
@@ -8,6 +8,7 @@
import
syntax
::
parse
::
parser
::
parse_sess
;
import
util
::
filesearch
;
import
back
::
target_strs
;
import
middle
::
lint
;
tag
os
{
os_win32
;
os_macos
;
os_linux
;
os_freebsd
;
}
...
...
@@ -33,7 +34,7 @@
debuginfo
:
bool
,
extra_debuginfo
:
bool
,
verify
:
bool
,
check_usage
:
bool
,
lint_opts
:
[
lint
::
option
]
,
save_temps
:
bool
,
stats
:
bool
,
time_passes
:
bool
,
...
...
src/comp/middle/check_usage.rs
已删除
100644 → 0
浏览文件 @
327a15d5
import
driver
::
session
::
session
;
import
middle
::
ty
::
ctxt
;
import
syntax
::{
ast
,
visit
};
type
crate_ctxt
=
{
tcx
:
ty
::
ctxt
};
fn
check_native_fn
(
ccx
:
@
crate_ctxt
,
decl
:
ast
::
fn_decl
)
{
let
tys
=
vec
::
map
(
decl
.inputs
)
{|
a
|
a
.ty
};
for
ty
in
(
tys
+
[
decl
.output
])
{
alt
ty
.node
{
ast
::
ty_int
(
ast
::
ty_i
.
)
{
ccx
.tcx.sess
.span_warn
(
ty
.span
,
"found rust type `int` in native module, while "
+
"ctypes::c_int or ctypes::long should be used"
);
}
ast
::
ty_uint
(
ast
::
ty_u
.
)
{
ccx
.tcx.sess
.span_warn
(
ty
.span
,
"found rust type `uint` in native module, while "
+
"ctypes::c_uint or ctypes::ulong should be used"
);
}
_
{
}
}
}
}
fn
check_item
(
ccx
:
@
crate_ctxt
,
it
:
@
ast
::
item
)
{
alt
it
.node
{
ast
::
item_native_mod
(
nmod
)
{
for
ni
in
nmod
.items
{
alt
ni
.node
{
ast
::
native_item_fn
(
decl
,
tps
)
{
check_native_fn
(
ccx
,
decl
);
}
_
{
}
}
}
}
_
{
/* nothing to do */
}
}
}
fn
check_crate
(
tcx
:
ty
::
ctxt
,
crate
:
@
ast
::
crate
)
{
let
ccx
=
@
{
tcx
:
tcx
};
let
visit
=
visit
::
mk_simple_visitor
(
@
{
visit_item
:
bind
check_item
(
ccx
,
_
)
with
*
visit
::
default_simple_visitor
()
});
visit
::
visit_crate
(
*
crate
,
(),
visit
);
tcx
.sess
.abort_if_errors
();
}
//
// Local Variables:
// mode: rust
// fill-column: 78;
// indent-tabs-mode: nil
// c-basic-offset: 4
// buffer-file-coding-system: utf-8-unix
// End:
//
src/comp/middle/lint.rs
0 → 100644
浏览文件 @
7ffb2cb7
import
driver
::
session
::
session
;
import
middle
::
ty
::
ctxt
;
import
syntax
::{
ast
,
visit
};
type
crate_ctxt
=
{
tcx
:
ty
::
ctxt
};
enum
option
{
ctypes
;
}
fn
check_crate
(
tcx
:
ty
::
ctxt
,
crate
:
@
ast
::
crate
,
checks
:
[
option
],
timer
:
block
(
str
,
fn
@
()))
{
let
ccx
=
@
{
tcx
:
tcx
};
vec
::
iter
(
checks
)
{|
c
|
alt
c
{
ctypes
{
timer
(
"ctypes usage checking"
,
bind
check_ctypes
(
ccx
,
crate
))
}
}
}
}
fn
check_ctypes
(
ccx
:
@
crate_ctxt
,
crate
:
@
ast
::
crate
)
{
fn
check_native_fn
(
ccx
:
@
crate_ctxt
,
decl
:
ast
::
fn_decl
)
{
let
tys
=
vec
::
map
(
decl
.inputs
)
{|
a
|
a
.ty
};
for
ty
in
(
tys
+
[
decl
.output
])
{
alt
ty
.node
{
ast
::
ty_int
(
ast
::
ty_i
)
{
ccx
.tcx.sess
.span_warn
(
ty
.span
,
"found rust type `int` in native module, while
\
ctypes::c_int or ctypes::long should be used"
);
}
ast
::
ty_uint
(
ast
::
ty_u
)
{
ccx
.tcx.sess
.span_warn
(
ty
.span
,
"found rust type `uint` in native module, while
\
ctypes::c_uint or ctypes::ulong should be used"
);
}
_
{
}
}
}
}
fn
check_item
(
ccx
:
@
crate_ctxt
,
it
:
@
ast
::
item
)
{
alt
it
.node
{
ast
::
item_native_mod
(
nmod
)
{
for
ni
in
nmod
.items
{
alt
ni
.node
{
ast
::
native_item_fn
(
decl
,
tps
)
{
check_native_fn
(
ccx
,
decl
);
}
_
{
}
}
}
}
_
{
/* nothing to do */
}
}
}
let
visit
=
visit
::
mk_simple_visitor
(
@
{
visit_item
:
bind
check_item
(
ccx
,
_
)
with
*
visit
::
default_simple_visitor
()
});
visit
::
visit_crate
(
*
crate
,
(),
visit
);
}
//
// Local Variables:
// mode: rust
// fill-column: 78;
// indent-tabs-mode: nil
// c-basic-offset: 4
// buffer-file-coding-system: utf-8-unix
// End:
//
src/comp/rustc.rc
浏览文件 @
7ffb2cb7
...
...
@@ -29,7 +29,7 @@ mod middle {
mod
fn_usage
;
mod
check_alt
;
mod
check_const
;
mod
check_usage
;
mod
lint
;
mod
mut
;
mod
alias
;
mod
last_use
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录