Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
e14562d5
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,发现更多精彩内容 >>
提交
e14562d5
编写于
11月 17, 2015
作者:
N
Niko Matsakis
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rework the `IdVisitor` so that it only visits item contents (and doesn't
visit nested items). This is what all clients wanted anyhow.
上级
25727d70
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
13 addition
and
34 deletion
+13
-34
src/librustc/lint/context.rs
src/librustc/lint/context.rs
+1
-6
src/librustc/metadata/inline.rs
src/librustc/metadata/inline.rs
+1
-5
src/librustc/middle/check_match.rs
src/librustc/middle/check_match.rs
+1
-5
src/libsyntax/ast_util.rs
src/libsyntax/ast_util.rs
+10
-18
未找到文件。
src/librustc/lint/context.rs
浏览文件 @
e14562d5
...
@@ -555,7 +555,6 @@ fn visit_ids<F>(&mut self, f: F)
...
@@ -555,7 +555,6 @@ fn visit_ids<F>(&mut self, f: F)
{
{
let
mut
v
=
ast_util
::
IdVisitor
{
let
mut
v
=
ast_util
::
IdVisitor
{
operation
:
self
,
operation
:
self
,
pass_through_items
:
false
,
visited_outermost
:
false
,
visited_outermost
:
false
,
};
};
f
(
&
mut
v
);
f
(
&
mut
v
);
...
@@ -583,11 +582,7 @@ fn new(tcx: &'a ty::ctxt<'tcx>,
...
@@ -583,11 +582,7 @@ fn new(tcx: &'a ty::ctxt<'tcx>,
fn
visit_ids
<
F
>
(
&
mut
self
,
f
:
F
)
fn
visit_ids
<
F
>
(
&
mut
self
,
f
:
F
)
where
F
:
FnOnce
(
&
mut
util
::
IdVisitor
<
LateContext
>
)
where
F
:
FnOnce
(
&
mut
util
::
IdVisitor
<
LateContext
>
)
{
{
let
mut
v
=
util
::
IdVisitor
{
let
mut
v
=
util
::
IdVisitor
::
new
(
self
);
operation
:
self
,
pass_through_items
:
false
,
visited_outermost
:
false
,
};
f
(
&
mut
v
);
f
(
&
mut
v
);
}
}
}
}
...
...
src/librustc/metadata/inline.rs
浏览文件 @
e14562d5
...
@@ -48,11 +48,7 @@ pub fn visit<'ast,V>(&'ast self, visitor: &mut V)
...
@@ -48,11 +48,7 @@ pub fn visit<'ast,V>(&'ast self, visitor: &mut V)
}
}
pub
fn
visit_ids
<
O
:
IdVisitingOperation
>
(
&
self
,
operation
:
&
mut
O
)
{
pub
fn
visit_ids
<
O
:
IdVisitingOperation
>
(
&
self
,
operation
:
&
mut
O
)
{
let
mut
id_visitor
=
IdVisitor
{
let
mut
id_visitor
=
IdVisitor
::
new
(
operation
);
operation
:
operation
,
pass_through_items
:
true
,
visited_outermost
:
false
,
};
self
.visit
(
&
mut
id_visitor
);
self
.visit
(
&
mut
id_visitor
);
}
}
...
...
src/librustc/middle/check_match.rs
浏览文件 @
e14562d5
...
@@ -485,11 +485,7 @@ fn record_renamings(const_expr: &hir::Expr,
...
@@ -485,11 +485,7 @@ fn record_renamings(const_expr: &hir::Expr,
renaming_map
:
renaming_map
,
renaming_map
:
renaming_map
,
};
};
let
mut
id_visitor
=
front_util
::
IdVisitor
{
let
mut
id_visitor
=
front_util
::
IdVisitor
::
new
(
&
mut
renaming_recorder
);
operation
:
&
mut
renaming_recorder
,
pass_through_items
:
true
,
visited_outermost
:
false
,
};
id_visitor
.visit_expr
(
const_expr
);
id_visitor
.visit_expr
(
const_expr
);
}
}
...
...
src/libsyntax/ast_util.rs
浏览文件 @
e14562d5
...
@@ -289,7 +289,6 @@ pub trait IdVisitingOperation {
...
@@ -289,7 +289,6 @@ pub trait IdVisitingOperation {
pub
struct
IdVisitor
<
'a
,
O
:
'a
>
{
pub
struct
IdVisitor
<
'a
,
O
:
'a
>
{
pub
operation
:
&
'a
mut
O
,
pub
operation
:
&
'a
mut
O
,
pub
pass_through_items
:
bool
,
pub
visited_outermost
:
bool
,
pub
visited_outermost
:
bool
,
}
}
...
@@ -319,13 +318,11 @@ fn visit_foreign_item(&mut self, foreign_item: &ForeignItem) {
...
@@ -319,13 +318,11 @@ fn visit_foreign_item(&mut self, foreign_item: &ForeignItem) {
}
}
fn
visit_item
(
&
mut
self
,
item
:
&
Item
)
{
fn
visit_item
(
&
mut
self
,
item
:
&
Item
)
{
if
!
self
.pass_through_items
{
if
self
.visited_outermost
{
if
self
.visited_outermost
{
return
return
}
else
{
}
else
{
self
.visited_outermost
=
true
self
.visited_outermost
=
true
}
}
}
self
.operation
.visit_id
(
item
.id
);
self
.operation
.visit_id
(
item
.id
);
match
item
.node
{
match
item
.node
{
...
@@ -390,13 +387,11 @@ fn visit_fn(&mut self,
...
@@ -390,13 +387,11 @@ fn visit_fn(&mut self,
block
:
&
'v
Block
,
block
:
&
'v
Block
,
span
:
Span
,
span
:
Span
,
node_id
:
NodeId
)
{
node_id
:
NodeId
)
{
if
!
self
.pass_through_items
{
match
function_kind
{
match
function_kind
{
FnKind
::
Method
(
..
)
if
self
.visited_outermost
=>
return
,
FnKind
::
Method
(
..
)
if
self
.visited_outermost
=>
return
,
FnKind
::
Method
(
..
)
=>
self
.visited_outermost
=
true
,
FnKind
::
Method
(
..
)
=>
self
.visited_outermost
=
true
,
_
=>
{}
_
=>
{}
}
}
}
self
.operation
.visit_id
(
node_id
);
self
.operation
.visit_id
(
node_id
);
...
@@ -420,12 +415,10 @@ fn visit_fn(&mut self,
...
@@ -420,12 +415,10 @@ fn visit_fn(&mut self,
block
,
block
,
span
);
span
);
if
!
self
.pass_through_items
{
if
let
FnKind
::
Method
(
..
)
=
function_kind
{
if
let
FnKind
::
Method
(
..
)
=
function_kind
{
self
.visited_outermost
=
false
;
self
.visited_outermost
=
false
;
}
}
}
}
}
fn
visit_struct_field
(
&
mut
self
,
struct_field
:
&
StructField
)
{
fn
visit_struct_field
(
&
mut
self
,
struct_field
:
&
StructField
)
{
self
.operation
.visit_id
(
struct_field
.node.id
);
self
.operation
.visit_id
(
struct_field
.node.id
);
...
@@ -497,7 +490,6 @@ pub fn compute_id_range_for_fn_body(fk: FnKind,
...
@@ -497,7 +490,6 @@ pub fn compute_id_range_for_fn_body(fk: FnKind,
let
mut
visitor
=
IdRangeComputingVisitor
::
new
();
let
mut
visitor
=
IdRangeComputingVisitor
::
new
();
let
mut
id_visitor
=
IdVisitor
{
let
mut
id_visitor
=
IdVisitor
{
operation
:
&
mut
visitor
,
operation
:
&
mut
visitor
,
pass_through_items
:
false
,
visited_outermost
:
false
,
visited_outermost
:
false
,
};
};
id_visitor
.visit_fn
(
fk
,
decl
,
body
,
sp
,
id
);
id_visitor
.visit_fn
(
fk
,
decl
,
body
,
sp
,
id
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录