Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
6fede934
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,发现更多精彩内容 >>
提交
6fede934
编写于
6月 17, 2014
作者:
K
Keegan McAllister
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make the crate and its exported items available in the lint context
上级
a813a377
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
15 addition
and
13 deletion
+15
-13
src/librustc/lint/builtin.rs
src/librustc/lint/builtin.rs
+2
-10
src/librustc/lint/context.rs
src/librustc/lint/context.rs
+13
-3
未找到文件。
src/librustc/lint/builtin.rs
浏览文件 @
6fede934
...
...
@@ -1238,9 +1238,6 @@ fn check_expr(&mut self, cx: &Context, e: &ast::Expr) {
"detects missing documentation for public members"
)
pub
struct
MissingDoc
{
/// Set of nodes exported from this module.
exported_items
:
Option
<
ExportedItems
>
,
/// Stack of IDs of struct definitions.
struct_def_stack
:
Vec
<
ast
::
NodeId
>
,
...
...
@@ -1252,7 +1249,6 @@ pub struct MissingDoc {
impl
MissingDoc
{
pub
fn
new
()
->
MissingDoc
{
MissingDoc
{
exported_items
:
None
,
struct_def_stack
:
vec!
(),
doc_hidden_stack
:
vec!
(
false
),
}
...
...
@@ -1278,9 +1274,8 @@ fn check_missing_doc_attrs(&self,
// Only check publicly-visible items, using the result from the privacy pass.
// It's an option so the crate root can also use this function (it doesn't
// have a NodeId).
let
exported
=
self
.exported_items
.as_ref
()
.expect
(
"exported_items not set"
);
match
id
{
Some
(
ref
id
)
if
!
exported
.contains
(
id
)
=>
return
,
Some
(
ref
id
)
if
!
cx
.exported_items
.contains
(
id
)
=>
return
,
_
=>
()
}
...
...
@@ -1327,10 +1322,7 @@ fn check_struct_def_post(&mut self, _: &Context,
assert
!
(
popped
==
id
);
}
fn
check_crate
(
&
mut
self
,
cx
:
&
Context
,
exported
:
&
ExportedItems
,
krate
:
&
ast
::
Crate
)
{
// FIXME: clone to avoid lifetime trickiness
self
.exported_items
=
Some
(
exported
.clone
());
fn
check_crate
(
&
mut
self
,
cx
:
&
Context
,
_
:
&
ExportedItems
,
krate
:
&
ast
::
Crate
)
{
self
.check_missing_doc_attrs
(
cx
,
None
,
krate
.attrs
.as_slice
(),
krate
.span
,
"crate"
);
}
...
...
src/librustc/lint/context.rs
浏览文件 @
6fede934
...
...
@@ -170,6 +170,12 @@ pub struct Context<'a> {
/// Type context we're checking in.
pub
tcx
:
&
'a
ty
::
ctxt
,
/// The crate being checked.
pub
krate
:
&
'a
ast
::
Crate
,
/// Items exported from the crate being checked.
pub
exported_items
:
&
'a
ExportedItems
,
/// The store of registered lints.
lints
:
LintStore
,
...
...
@@ -275,14 +281,18 @@ pub fn raw_emit_lint(sess: &Session, lint: &'static Lint,
}
impl
<
'a
>
Context
<
'a
>
{
fn
new
(
tcx
:
&
'a
ty
::
ctxt
)
->
Context
<
'a
>
{
fn
new
(
tcx
:
&
'a
ty
::
ctxt
,
krate
:
&
'a
ast
::
Crate
,
exported_items
:
&
'a
ExportedItems
)
->
Context
<
'a
>
{
// We want to own the lint store, so move it out of the session.
let
lint_store
=
mem
::
replace
(
&
mut
*
tcx
.sess.lint_store
.borrow_mut
(),
LintStore
::
new
());
Context
{
lints
:
lint_store
,
tcx
:
tcx
,
krate
:
krate
,
exported_items
:
exported_items
,
lints
:
lint_store
,
level_stack
:
vec!
(),
node_levels
:
RefCell
::
new
(
HashMap
::
new
()),
}
...
...
@@ -619,7 +629,7 @@ fn check_item(&mut self, cx: &Context, it: &ast::Item) {
pub
fn
check_crate
(
tcx
:
&
ty
::
ctxt
,
krate
:
&
ast
::
Crate
,
exported_items
:
&
ExportedItems
)
{
let
mut
cx
=
Context
::
new
(
tcx
);
let
mut
cx
=
Context
::
new
(
tcx
,
krate
,
exported_items
);
// Visit the whole crate.
cx
.with_lint_attrs
(
krate
.attrs
.as_slice
(),
|
cx
|
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录