Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
ae77dbb8
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,发现更多精彩内容 >>
提交
ae77dbb8
编写于
9月 20, 2015
作者:
V
Vadim Petrochenkov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use Names in HIR visitors and folders
上级
885d2242
变更
11
显示空白变更内容
内联
并排
Showing
11 changed file
with
67 addition
and
65 deletion
+67
-65
src/librustc/front/map/blocks.rs
src/librustc/front/map/blocks.rs
+3
-3
src/librustc/lint/context.rs
src/librustc/lint/context.rs
+5
-5
src/librustc/lint/mod.rs
src/librustc/lint/mod.rs
+3
-3
src/librustc/middle/dead.rs
src/librustc/middle/dead.rs
+1
-1
src/librustc_back/svh.rs
src/librustc_back/svh.rs
+5
-5
src/librustc_front/fold.rs
src/librustc_front/fold.rs
+22
-18
src/librustc_front/util.rs
src/librustc_front/util.rs
+2
-2
src/librustc_front/visit.rs
src/librustc_front/visit.rs
+22
-24
src/librustc_lint/builtin.rs
src/librustc_lint/builtin.rs
+2
-2
src/librustc_privacy/lib.rs
src/librustc_privacy/lib.rs
+1
-1
src/librustc_resolve/lib.rs
src/librustc_resolve/lib.rs
+1
-1
未找到文件。
src/librustc/front/map/blocks.rs
浏览文件 @
ae77dbb8
...
@@ -189,13 +189,13 @@ pub fn id(self) -> NodeId {
...
@@ -189,13 +189,13 @@ pub fn id(self) -> NodeId {
pub
fn
kind
(
self
)
->
FnKind
<
'a
>
{
pub
fn
kind
(
self
)
->
FnKind
<
'a
>
{
let
item
=
|
p
:
ItemFnParts
<
'a
>
|
->
FnKind
<
'a
>
{
let
item
=
|
p
:
ItemFnParts
<
'a
>
|
->
FnKind
<
'a
>
{
FnKind
::
ItemFn
(
p
.ident
,
p
.generics
,
p
.unsafety
,
p
.constness
,
p
.abi
,
p
.vis
)
FnKind
::
ItemFn
(
p
.ident
.name
,
p
.generics
,
p
.unsafety
,
p
.constness
,
p
.abi
,
p
.vis
)
};
};
let
closure
=
|
_
:
ClosureParts
|
{
let
closure
=
|
_
:
ClosureParts
|
{
FnKind
::
Closure
FnKind
::
Closure
};
};
let
method
=
|
_
,
ident
,
sig
:
&
'a
ast
::
MethodSig
,
vis
,
_
,
_
|
{
let
method
=
|
_
,
ident
:
Ident
,
sig
:
&
'a
ast
::
MethodSig
,
vis
,
_
,
_
|
{
FnKind
::
Method
(
ident
,
sig
,
vis
)
FnKind
::
Method
(
ident
.name
,
sig
,
vis
)
};
};
self
.handle
(
item
,
method
,
closure
)
self
.handle
(
item
,
method
,
closure
)
}
}
...
...
src/librustc/lint/context.rs
浏览文件 @
ae77dbb8
...
@@ -663,12 +663,12 @@ fn visit_fn(&mut self, fk: hir_visit::FnKind<'v>, decl: &'v hir::FnDecl,
...
@@ -663,12 +663,12 @@ fn visit_fn(&mut self, fk: hir_visit::FnKind<'v>, decl: &'v hir::FnDecl,
fn
visit_struct_def
(
&
mut
self
,
fn
visit_struct_def
(
&
mut
self
,
s
:
&
hir
::
StructDef
,
s
:
&
hir
::
StructDef
,
ident
:
ast
::
Ident
,
name
:
ast
::
Name
,
g
:
&
hir
::
Generics
,
g
:
&
hir
::
Generics
,
id
:
ast
::
NodeId
)
{
id
:
ast
::
NodeId
)
{
run_lints!
(
self
,
check_struct_def
,
late_passes
,
s
,
ident
,
g
,
id
);
run_lints!
(
self
,
check_struct_def
,
late_passes
,
s
,
name
,
g
,
id
);
hir_visit
::
walk_struct_def
(
self
,
s
);
hir_visit
::
walk_struct_def
(
self
,
s
);
run_lints!
(
self
,
check_struct_def_post
,
late_passes
,
s
,
ident
,
g
,
id
);
run_lints!
(
self
,
check_struct_def_post
,
late_passes
,
s
,
name
,
g
,
id
);
}
}
fn
visit_struct_field
(
&
mut
self
,
s
:
&
hir
::
StructField
)
{
fn
visit_struct_field
(
&
mut
self
,
s
:
&
hir
::
StructField
)
{
...
@@ -691,8 +691,8 @@ fn visit_ty(&mut self, t: &hir::Ty) {
...
@@ -691,8 +691,8 @@ fn visit_ty(&mut self, t: &hir::Ty) {
hir_visit
::
walk_ty
(
self
,
t
);
hir_visit
::
walk_ty
(
self
,
t
);
}
}
fn
visit_
ident
(
&
mut
self
,
sp
:
Span
,
id
:
ast
::
Ident
)
{
fn
visit_
name
(
&
mut
self
,
sp
:
Span
,
name
:
ast
::
Name
)
{
run_lints!
(
self
,
check_
ident
,
late_passes
,
sp
,
id
);
run_lints!
(
self
,
check_
name
,
late_passes
,
sp
,
name
);
}
}
fn
visit_mod
(
&
mut
self
,
m
:
&
hir
::
Mod
,
s
:
Span
,
n
:
ast
::
NodeId
)
{
fn
visit_mod
(
&
mut
self
,
m
:
&
hir
::
Mod
,
s
:
Span
,
n
:
ast
::
NodeId
)
{
...
...
src/librustc/lint/mod.rs
浏览文件 @
ae77dbb8
...
@@ -130,7 +130,7 @@ pub trait LintPass {
...
@@ -130,7 +130,7 @@ pub trait LintPass {
// FIXME: eliminate the duplication with `Visitor`. But this also
// FIXME: eliminate the duplication with `Visitor`. But this also
// contains a few lint-specific methods with no equivalent in `Visitor`.
// contains a few lint-specific methods with no equivalent in `Visitor`.
pub
trait
LateLintPass
:
LintPass
{
pub
trait
LateLintPass
:
LintPass
{
fn
check_
ident
(
&
mut
self
,
_
:
&
LateContext
,
_
:
Span
,
_
:
ast
::
Ident
)
{
}
fn
check_
name
(
&
mut
self
,
_
:
&
LateContext
,
_
:
Span
,
_
:
ast
::
Name
)
{
}
fn
check_crate
(
&
mut
self
,
_
:
&
LateContext
,
_
:
&
hir
::
Crate
)
{
}
fn
check_crate
(
&
mut
self
,
_
:
&
LateContext
,
_
:
&
hir
::
Crate
)
{
}
fn
check_mod
(
&
mut
self
,
_
:
&
LateContext
,
_
:
&
hir
::
Mod
,
_
:
Span
,
_
:
ast
::
NodeId
)
{
}
fn
check_mod
(
&
mut
self
,
_
:
&
LateContext
,
_
:
&
hir
::
Mod
,
_
:
Span
,
_
:
ast
::
NodeId
)
{
}
fn
check_foreign_item
(
&
mut
self
,
_
:
&
LateContext
,
_
:
&
hir
::
ForeignItem
)
{
}
fn
check_foreign_item
(
&
mut
self
,
_
:
&
LateContext
,
_
:
&
hir
::
ForeignItem
)
{
}
...
@@ -150,9 +150,9 @@ fn check_fn(&mut self, _: &LateContext,
...
@@ -150,9 +150,9 @@ fn check_fn(&mut self, _: &LateContext,
fn
check_trait_item
(
&
mut
self
,
_
:
&
LateContext
,
_
:
&
hir
::
TraitItem
)
{
}
fn
check_trait_item
(
&
mut
self
,
_
:
&
LateContext
,
_
:
&
hir
::
TraitItem
)
{
}
fn
check_impl_item
(
&
mut
self
,
_
:
&
LateContext
,
_
:
&
hir
::
ImplItem
)
{
}
fn
check_impl_item
(
&
mut
self
,
_
:
&
LateContext
,
_
:
&
hir
::
ImplItem
)
{
}
fn
check_struct_def
(
&
mut
self
,
_
:
&
LateContext
,
fn
check_struct_def
(
&
mut
self
,
_
:
&
LateContext
,
_
:
&
hir
::
StructDef
,
_
:
ast
::
Ident
,
_
:
&
hir
::
Generics
,
_
:
ast
::
NodeId
)
{
}
_
:
&
hir
::
StructDef
,
_
:
ast
::
Name
,
_
:
&
hir
::
Generics
,
_
:
ast
::
NodeId
)
{
}
fn
check_struct_def_post
(
&
mut
self
,
_
:
&
LateContext
,
fn
check_struct_def_post
(
&
mut
self
,
_
:
&
LateContext
,
_
:
&
hir
::
StructDef
,
_
:
ast
::
Ident
,
_
:
&
hir
::
Generics
,
_
:
ast
::
NodeId
)
{
}
_
:
&
hir
::
StructDef
,
_
:
ast
::
Name
,
_
:
&
hir
::
Generics
,
_
:
ast
::
NodeId
)
{
}
fn
check_struct_field
(
&
mut
self
,
_
:
&
LateContext
,
_
:
&
hir
::
StructField
)
{
}
fn
check_struct_field
(
&
mut
self
,
_
:
&
LateContext
,
_
:
&
hir
::
StructField
)
{
}
fn
check_variant
(
&
mut
self
,
_
:
&
LateContext
,
_
:
&
hir
::
Variant
,
_
:
&
hir
::
Generics
)
{
}
fn
check_variant
(
&
mut
self
,
_
:
&
LateContext
,
_
:
&
hir
::
Variant
,
_
:
&
hir
::
Generics
)
{
}
fn
check_variant_post
(
&
mut
self
,
_
:
&
LateContext
,
_
:
&
hir
::
Variant
,
_
:
&
hir
::
Generics
)
{
}
fn
check_variant_post
(
&
mut
self
,
_
:
&
LateContext
,
_
:
&
hir
::
Variant
,
_
:
&
hir
::
Generics
)
{
}
...
...
src/librustc/middle/dead.rs
浏览文件 @
ae77dbb8
...
@@ -207,7 +207,7 @@ fn visit_node(&mut self, node: &ast_map::Node) {
...
@@ -207,7 +207,7 @@ fn visit_node(&mut self, node: &ast_map::Node) {
impl
<
'a
,
'tcx
,
'v
>
Visitor
<
'v
>
for
MarkSymbolVisitor
<
'a
,
'tcx
>
{
impl
<
'a
,
'tcx
,
'v
>
Visitor
<
'v
>
for
MarkSymbolVisitor
<
'a
,
'tcx
>
{
fn
visit_struct_def
(
&
mut
self
,
def
:
&
hir
::
StructDef
,
_
:
ast
::
Ident
,
fn
visit_struct_def
(
&
mut
self
,
def
:
&
hir
::
StructDef
,
_
:
ast
::
Name
,
_
:
&
hir
::
Generics
,
_
:
ast
::
NodeId
)
{
_
:
&
hir
::
Generics
,
_
:
ast
::
NodeId
)
{
let
has_extern_repr
=
self
.struct_has_extern_repr
;
let
has_extern_repr
=
self
.struct_has_extern_repr
;
let
inherited_pub_visibility
=
self
.inherited_pub_visibility
;
let
inherited_pub_visibility
=
self
.inherited_pub_visibility
;
...
...
src/librustc_back/svh.rs
浏览文件 @
ae77dbb8
...
@@ -131,7 +131,7 @@ mod svh_visitor {
...
@@ -131,7 +131,7 @@ mod svh_visitor {
pub
use
self
::
SawExprComponent
::
*
;
pub
use
self
::
SawExprComponent
::
*
;
pub
use
self
::
SawStmtComponent
::
*
;
pub
use
self
::
SawStmtComponent
::
*
;
use
self
::
SawAbiComponent
::
*
;
use
self
::
SawAbiComponent
::
*
;
use
syntax
::
ast
::{
self
,
N
odeId
,
Ident
};
use
syntax
::
ast
::{
self
,
N
ame
,
NodeId
};
use
syntax
::
codemap
::
Span
;
use
syntax
::
codemap
::
Span
;
use
syntax
::
parse
::
token
;
use
syntax
::
parse
::
token
;
use
rustc_front
::
visit
;
use
rustc_front
::
visit
;
...
@@ -302,9 +302,9 @@ fn saw_stmt(node: &Stmt_) -> SawStmtComponent {
...
@@ -302,9 +302,9 @@ fn saw_stmt(node: &Stmt_) -> SawStmtComponent {
}
}
impl
<
'a
,
'v
>
Visitor
<
'v
>
for
StrictVersionHashVisitor
<
'a
>
{
impl
<
'a
,
'v
>
Visitor
<
'v
>
for
StrictVersionHashVisitor
<
'a
>
{
fn
visit_struct_def
(
&
mut
self
,
s
:
&
StructDef
,
ident
:
Ident
,
fn
visit_struct_def
(
&
mut
self
,
s
:
&
StructDef
,
name
:
Name
,
g
:
&
Generics
,
_
:
NodeId
)
{
g
:
&
Generics
,
_
:
NodeId
)
{
SawStructDef
(
ident
.
name
.as_str
())
.hash
(
self
.st
);
SawStructDef
(
name
.as_str
())
.hash
(
self
.st
);
visit
::
walk_generics
(
self
,
g
);
visit
::
walk_generics
(
self
,
g
);
visit
::
walk_struct_def
(
self
,
s
)
visit
::
walk_struct_def
(
self
,
s
)
}
}
...
@@ -341,8 +341,8 @@ fn visit_opt_lifetime_ref(&mut self, _: Span, l: &Option<Lifetime>) {
...
@@ -341,8 +341,8 @@ fn visit_opt_lifetime_ref(&mut self, _: Span, l: &Option<Lifetime>) {
// (If you edit a method such that it deviates from the
// (If you edit a method such that it deviates from the
// pattern, please move that method up above this comment.)
// pattern, please move that method up above this comment.)
fn
visit_
ident
(
&
mut
self
,
_
:
Span
,
ident
:
Ident
)
{
fn
visit_
name
(
&
mut
self
,
_
:
Span
,
name
:
Name
)
{
SawIdent
(
ident
.
name
.as_str
())
.hash
(
self
.st
);
SawIdent
(
name
.as_str
())
.hash
(
self
.st
);
}
}
fn
visit_lifetime_ref
(
&
mut
self
,
l
:
&
Lifetime
)
{
fn
visit_lifetime_ref
(
&
mut
self
,
l
:
&
Lifetime
)
{
...
...
src/librustc_front/fold.rs
浏览文件 @
ae77dbb8
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
//! and returns a piece of the same type.
//! and returns a piece of the same type.
use
hir
::
*
;
use
hir
::
*
;
use
syntax
::
ast
::{
Ident
,
NodeId
,
DUMMY_NODE_ID
,
Attribute
,
Attribute_
,
MetaItem
};
use
syntax
::
ast
::{
Ident
,
N
ame
,
N
odeId
,
DUMMY_NODE_ID
,
Attribute
,
Attribute_
,
MetaItem
};
use
syntax
::
ast
::{
MetaWord
,
MetaList
,
MetaNameValue
};
use
syntax
::
ast
::{
MetaWord
,
MetaList
,
MetaNameValue
};
use
hir
;
use
hir
;
use
syntax
::
codemap
::{
respan
,
Span
,
Spanned
};
use
syntax
::
codemap
::{
respan
,
Span
,
Spanned
};
...
@@ -147,8 +147,8 @@ fn fold_variant(&mut self, v: P<Variant>) -> P<Variant> {
...
@@ -147,8 +147,8 @@ fn fold_variant(&mut self, v: P<Variant>) -> P<Variant> {
noop_fold_variant
(
v
,
self
)
noop_fold_variant
(
v
,
self
)
}
}
fn
fold_
ident
(
&
mut
self
,
i
:
Ident
)
->
Ident
{
fn
fold_
name
(
&
mut
self
,
n
:
Name
)
->
Name
{
noop_fold_
ident
(
i
,
self
)
noop_fold_
name
(
n
,
self
)
}
}
fn
fold_usize
(
&
mut
self
,
i
:
usize
)
->
usize
{
fn
fold_usize
(
&
mut
self
,
i
:
usize
)
->
usize
{
...
@@ -284,6 +284,10 @@ fn new_span(&mut self, sp: Span) -> Span {
...
@@ -284,6 +284,10 @@ fn new_span(&mut self, sp: Span) -> Span {
}
}
}
}
fn
fold_ident
<
T
:
Folder
>
(
f
:
&
mut
T
,
i
:
Ident
)
->
Ident
{
Ident
{
name
:
f
.fold_name
(
i
.name
),
ctxt
:
i
.ctxt
}
}
pub
fn
noop_fold_meta_items
<
T
:
Folder
>
(
meta_items
:
Vec
<
P
<
MetaItem
>>
,
fld
:
&
mut
T
)
pub
fn
noop_fold_meta_items
<
T
:
Folder
>
(
meta_items
:
Vec
<
P
<
MetaItem
>>
,
fld
:
&
mut
T
)
->
Vec
<
P
<
MetaItem
>>
{
->
Vec
<
P
<
MetaItem
>>
{
meta_items
.move_map
(|
x
|
fld
.fold_meta_item
(
x
))
meta_items
.move_map
(|
x
|
fld
.fold_meta_item
(
x
))
...
@@ -435,8 +439,8 @@ pub fn noop_fold_variant<T: Folder>(v: P<Variant>, fld: &mut T) -> P<Variant> {
...
@@ -435,8 +439,8 @@ pub fn noop_fold_variant<T: Folder>(v: P<Variant>, fld: &mut T) -> P<Variant> {
})
})
}
}
pub
fn
noop_fold_
ident
<
T
:
Folder
>
(
i
:
Ident
,
_
:
&
mut
T
)
->
Ident
{
pub
fn
noop_fold_
name
<
T
:
Folder
>
(
n
:
Name
,
_
:
&
mut
T
)
->
Name
{
i
n
}
}
pub
fn
noop_fold_usize
<
T
:
Folder
>
(
i
:
usize
,
_
:
&
mut
T
)
->
usize
{
pub
fn
noop_fold_usize
<
T
:
Folder
>
(
i
:
usize
,
_
:
&
mut
T
)
->
usize
{
...
@@ -447,7 +451,7 @@ pub fn noop_fold_path<T: Folder>(Path {global, segments, span}: Path, fld: &mut
...
@@ -447,7 +451,7 @@ pub fn noop_fold_path<T: Folder>(Path {global, segments, span}: Path, fld: &mut
Path
{
Path
{
global
:
global
,
global
:
global
,
segments
:
segments
.move_map
(|
PathSegment
{
identifier
,
parameters
}|
PathSegment
{
segments
:
segments
.move_map
(|
PathSegment
{
identifier
,
parameters
}|
PathSegment
{
identifier
:
f
ld
.fold_ident
(
identifier
),
identifier
:
f
old_ident
(
fld
,
identifier
),
parameters
:
fld
.fold_path_parameters
(
parameters
),
parameters
:
fld
.fold_path_parameters
(
parameters
),
}),
}),
span
:
fld
.new_span
(
span
)
span
:
fld
.new_span
(
span
)
...
@@ -719,7 +723,7 @@ pub fn noop_fold_struct_field<T: Folder>(f: StructField, fld: &mut T) -> StructF
...
@@ -719,7 +723,7 @@ pub fn noop_fold_struct_field<T: Folder>(f: StructField, fld: &mut T) -> StructF
pub
fn
noop_fold_field
<
T
:
Folder
>
(
Field
{
ident
,
expr
,
span
}:
Field
,
folder
:
&
mut
T
)
->
Field
{
pub
fn
noop_fold_field
<
T
:
Folder
>
(
Field
{
ident
,
expr
,
span
}:
Field
,
folder
:
&
mut
T
)
->
Field
{
Field
{
Field
{
ident
:
respan
(
ident
.span
,
fold
er
.fold_ident
(
ident
.node
)),
ident
:
respan
(
ident
.span
,
fold
_ident
(
folder
,
ident
.node
)),
expr
:
folder
.fold_expr
(
expr
),
expr
:
folder
.fold_expr
(
expr
),
span
:
folder
.new_span
(
span
)
span
:
folder
.new_span
(
span
)
}
}
...
@@ -835,7 +839,7 @@ pub fn noop_fold_trait_item<T: Folder>(i: P<TraitItem>, folder: &mut T)
...
@@ -835,7 +839,7 @@ pub fn noop_fold_trait_item<T: Folder>(i: P<TraitItem>, folder: &mut T)
->
SmallVector
<
P
<
TraitItem
>>
{
->
SmallVector
<
P
<
TraitItem
>>
{
SmallVector
::
one
(
i
.map
(|
TraitItem
{
id
,
ident
,
attrs
,
node
,
span
}|
TraitItem
{
SmallVector
::
one
(
i
.map
(|
TraitItem
{
id
,
ident
,
attrs
,
node
,
span
}|
TraitItem
{
id
:
folder
.new_id
(
id
),
id
:
folder
.new_id
(
id
),
ident
:
fold
er
.fold_ident
(
ident
),
ident
:
fold
_ident
(
folder
,
ident
),
attrs
:
fold_attrs
(
attrs
,
folder
),
attrs
:
fold_attrs
(
attrs
,
folder
),
node
:
match
node
{
node
:
match
node
{
ConstTraitItem
(
ty
,
default
)
=>
{
ConstTraitItem
(
ty
,
default
)
=>
{
...
@@ -859,7 +863,7 @@ pub fn noop_fold_impl_item<T: Folder>(i: P<ImplItem>, folder: &mut T)
...
@@ -859,7 +863,7 @@ pub fn noop_fold_impl_item<T: Folder>(i: P<ImplItem>, folder: &mut T)
->
SmallVector
<
P
<
ImplItem
>>
{
->
SmallVector
<
P
<
ImplItem
>>
{
SmallVector
::
one
(
i
.map
(|
ImplItem
{
id
,
ident
,
attrs
,
node
,
vis
,
span
}|
ImplItem
{
SmallVector
::
one
(
i
.map
(|
ImplItem
{
id
,
ident
,
attrs
,
node
,
vis
,
span
}|
ImplItem
{
id
:
folder
.new_id
(
id
),
id
:
folder
.new_id
(
id
),
ident
:
fold
er
.fold_ident
(
ident
),
ident
:
fold
_ident
(
folder
,
ident
),
attrs
:
fold_attrs
(
attrs
,
folder
),
attrs
:
fold_attrs
(
attrs
,
folder
),
vis
:
vis
,
vis
:
vis
,
node
:
match
node
{
node
:
match
node
{
...
@@ -943,7 +947,7 @@ pub fn noop_fold_item_simple<T: Folder>(Item {id, ident, attrs, node, vis, span}
...
@@ -943,7 +947,7 @@ pub fn noop_fold_item_simple<T: Folder>(Item {id, ident, attrs, node, vis, span}
Item
{
Item
{
id
:
id
,
id
:
id
,
ident
:
fold
er
.fold_ident
(
ident
),
ident
:
fold
_ident
(
folder
,
ident
),
attrs
:
fold_attrs
(
attrs
,
folder
),
attrs
:
fold_attrs
(
attrs
,
folder
),
node
:
node
,
node
:
node
,
vis
:
vis
,
vis
:
vis
,
...
@@ -954,7 +958,7 @@ pub fn noop_fold_item_simple<T: Folder>(Item {id, ident, attrs, node, vis, span}
...
@@ -954,7 +958,7 @@ pub fn noop_fold_item_simple<T: Folder>(Item {id, ident, attrs, node, vis, span}
pub
fn
noop_fold_foreign_item
<
T
:
Folder
>
(
ni
:
P
<
ForeignItem
>
,
folder
:
&
mut
T
)
->
P
<
ForeignItem
>
{
pub
fn
noop_fold_foreign_item
<
T
:
Folder
>
(
ni
:
P
<
ForeignItem
>
,
folder
:
&
mut
T
)
->
P
<
ForeignItem
>
{
ni
.map
(|
ForeignItem
{
id
,
ident
,
attrs
,
node
,
span
,
vis
}|
ForeignItem
{
ni
.map
(|
ForeignItem
{
id
,
ident
,
attrs
,
node
,
span
,
vis
}|
ForeignItem
{
id
:
folder
.new_id
(
id
),
id
:
folder
.new_id
(
id
),
ident
:
fold
er
.fold_ident
(
ident
),
ident
:
fold
_ident
(
folder
,
ident
),
attrs
:
fold_attrs
(
attrs
,
folder
),
attrs
:
fold_attrs
(
attrs
,
folder
),
node
:
match
node
{
node
:
match
node
{
ForeignItemFn
(
fdec
,
generics
)
=>
{
ForeignItemFn
(
fdec
,
generics
)
=>
{
...
@@ -988,7 +992,7 @@ pub fn noop_fold_pat<T: Folder>(p: P<Pat>, folder: &mut T) -> P<Pat> {
...
@@ -988,7 +992,7 @@ pub fn noop_fold_pat<T: Folder>(p: P<Pat>, folder: &mut T) -> P<Pat> {
PatIdent
(
binding_mode
,
pth1
,
sub
)
=>
{
PatIdent
(
binding_mode
,
pth1
,
sub
)
=>
{
PatIdent
(
binding_mode
,
PatIdent
(
binding_mode
,
Spanned
{
span
:
folder
.new_span
(
pth1
.span
),
Spanned
{
span
:
folder
.new_span
(
pth1
.span
),
node
:
fold
er
.fold_ident
(
pth1
.node
)},
node
:
fold
_ident
(
folder
,
pth1
.node
)},
sub
.map
(|
x
|
folder
.fold_pat
(
x
)))
sub
.map
(|
x
|
folder
.fold_pat
(
x
)))
}
}
PatLit
(
e
)
=>
PatLit
(
folder
.fold_expr
(
e
)),
PatLit
(
e
)
=>
PatLit
(
folder
.fold_expr
(
e
)),
...
@@ -1048,7 +1052,7 @@ pub fn noop_fold_expr<T: Folder>(Expr {id, node, span}: Expr, folder: &mut T) ->
...
@@ -1048,7 +1052,7 @@ pub fn noop_fold_expr<T: Folder>(Expr {id, node, span}: Expr, folder: &mut T) ->
}
}
ExprMethodCall
(
i
,
tps
,
args
)
=>
{
ExprMethodCall
(
i
,
tps
,
args
)
=>
{
ExprMethodCall
(
ExprMethodCall
(
respan
(
folder
.new_span
(
i
.span
),
fold
er
.fold_ident
(
i
.node
)),
respan
(
folder
.new_span
(
i
.span
),
fold
_ident
(
folder
,
i
.node
)),
tps
.move_map
(|
x
|
folder
.fold_ty
(
x
)),
tps
.move_map
(|
x
|
folder
.fold_ty
(
x
)),
args
.move_map
(|
x
|
folder
.fold_expr
(
x
)))
args
.move_map
(|
x
|
folder
.fold_expr
(
x
)))
}
}
...
@@ -1073,11 +1077,11 @@ pub fn noop_fold_expr<T: Folder>(Expr {id, node, span}: Expr, folder: &mut T) ->
...
@@ -1073,11 +1077,11 @@ pub fn noop_fold_expr<T: Folder>(Expr {id, node, span}: Expr, folder: &mut T) ->
ExprWhile
(
cond
,
body
,
opt_ident
)
=>
{
ExprWhile
(
cond
,
body
,
opt_ident
)
=>
{
ExprWhile
(
folder
.fold_expr
(
cond
),
ExprWhile
(
folder
.fold_expr
(
cond
),
folder
.fold_block
(
body
),
folder
.fold_block
(
body
),
opt_ident
.map
(|
i
|
fold
er
.fold_ident
(
i
)))
opt_ident
.map
(|
i
|
fold
_ident
(
folder
,
i
)))
}
}
ExprLoop
(
body
,
opt_ident
)
=>
{
ExprLoop
(
body
,
opt_ident
)
=>
{
ExprLoop
(
folder
.fold_block
(
body
),
ExprLoop
(
folder
.fold_block
(
body
),
opt_ident
.map
(|
i
|
fold
er
.fold_ident
(
i
)))
opt_ident
.map
(|
i
|
fold
_ident
(
folder
,
i
)))
}
}
ExprMatch
(
expr
,
arms
,
source
)
=>
{
ExprMatch
(
expr
,
arms
,
source
)
=>
{
ExprMatch
(
folder
.fold_expr
(
expr
),
ExprMatch
(
folder
.fold_expr
(
expr
),
...
@@ -1101,7 +1105,7 @@ pub fn noop_fold_expr<T: Folder>(Expr {id, node, span}: Expr, folder: &mut T) ->
...
@@ -1101,7 +1105,7 @@ pub fn noop_fold_expr<T: Folder>(Expr {id, node, span}: Expr, folder: &mut T) ->
ExprField
(
el
,
ident
)
=>
{
ExprField
(
el
,
ident
)
=>
{
ExprField
(
folder
.fold_expr
(
el
),
ExprField
(
folder
.fold_expr
(
el
),
respan
(
folder
.new_span
(
ident
.span
),
respan
(
folder
.new_span
(
ident
.span
),
fold
er
.fold_ident
(
ident
.node
)))
fold
_ident
(
folder
,
ident
.node
)))
}
}
ExprTupField
(
el
,
ident
)
=>
{
ExprTupField
(
el
,
ident
)
=>
{
ExprTupField
(
folder
.fold_expr
(
el
),
ExprTupField
(
folder
.fold_expr
(
el
),
...
@@ -1126,11 +1130,11 @@ pub fn noop_fold_expr<T: Folder>(Expr {id, node, span}: Expr, folder: &mut T) ->
...
@@ -1126,11 +1130,11 @@ pub fn noop_fold_expr<T: Folder>(Expr {id, node, span}: Expr, folder: &mut T) ->
}
}
ExprBreak
(
opt_ident
)
=>
ExprBreak
(
opt_ident
.map
(|
label
|
ExprBreak
(
opt_ident
)
=>
ExprBreak
(
opt_ident
.map
(|
label
|
respan
(
folder
.new_span
(
label
.span
),
respan
(
folder
.new_span
(
label
.span
),
fold
er
.fold_ident
(
label
.node
)))
fold
_ident
(
folder
,
label
.node
)))
),
),
ExprAgain
(
opt_ident
)
=>
ExprAgain
(
opt_ident
.map
(|
label
|
ExprAgain
(
opt_ident
)
=>
ExprAgain
(
opt_ident
.map
(|
label
|
respan
(
folder
.new_span
(
label
.span
),
respan
(
folder
.new_span
(
label
.span
),
fold
er
.fold_ident
(
label
.node
)))
fold
_ident
(
folder
,
label
.node
)))
),
),
ExprRet
(
e
)
=>
ExprRet
(
e
.map
(|
x
|
folder
.fold_expr
(
x
))),
ExprRet
(
e
)
=>
ExprRet
(
e
.map
(|
x
|
folder
.fold_expr
(
x
))),
ExprInlineAsm
(
InlineAsm
{
ExprInlineAsm
(
InlineAsm
{
...
...
src/librustc_front/util.rs
浏览文件 @
ae77dbb8
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
use
hir
::
*
;
use
hir
::
*
;
use
visit
::{
self
,
Visitor
,
FnKind
};
use
visit
::{
self
,
Visitor
,
FnKind
};
use
syntax
::
ast_util
;
use
syntax
::
ast_util
;
use
syntax
::
ast
::{
Ident
,
NodeId
,
DUMMY_NODE_ID
};
use
syntax
::
ast
::{
Ident
,
N
ame
,
N
odeId
,
DUMMY_NODE_ID
};
use
syntax
::
codemap
::
Span
;
use
syntax
::
codemap
::
Span
;
use
syntax
::
ptr
::
P
;
use
syntax
::
ptr
::
P
;
use
syntax
::
owned_slice
::
OwnedSlice
;
use
syntax
::
owned_slice
::
OwnedSlice
;
...
@@ -286,7 +286,7 @@ fn visit_struct_field(&mut self, struct_field: &StructField) {
...
@@ -286,7 +286,7 @@ fn visit_struct_field(&mut self, struct_field: &StructField) {
fn
visit_struct_def
(
&
mut
self
,
fn
visit_struct_def
(
&
mut
self
,
struct_def
:
&
StructDef
,
struct_def
:
&
StructDef
,
_
:
Ident
,
_
:
Name
,
_
:
&
hir
::
Generics
,
_
:
&
hir
::
Generics
,
id
:
NodeId
)
{
id
:
NodeId
)
{
self
.operation
.visit_id
(
id
);
self
.operation
.visit_id
(
id
);
...
...
src/librustc_front/visit.rs
浏览文件 @
ae77dbb8
...
@@ -24,7 +24,7 @@
...
@@ -24,7 +24,7 @@
//! those that are created by the expansion of a macro.
//! those that are created by the expansion of a macro.
use
syntax
::
abi
::
Abi
;
use
syntax
::
abi
::
Abi
;
use
syntax
::
ast
::{
Ident
,
NodeId
,
CRATE_NODE_ID
,
Name
,
Attribute
};
use
syntax
::
ast
::{
NodeId
,
CRATE_NODE_ID
,
Name
,
Attribute
};
use
hir
::
*
;
use
hir
::
*
;
use
hir
;
use
hir
;
use
syntax
::
codemap
::
Span
;
use
syntax
::
codemap
::
Span
;
...
@@ -34,10 +34,10 @@
...
@@ -34,10 +34,10 @@
#[derive(Copy,
Clone,
PartialEq,
Eq)]
#[derive(Copy,
Clone,
PartialEq,
Eq)]
pub
enum
FnKind
<
'a
>
{
pub
enum
FnKind
<
'a
>
{
/// fn foo() or extern "Abi" fn foo()
/// fn foo() or extern "Abi" fn foo()
ItemFn
(
Ident
,
&
'a
Generics
,
Unsafety
,
Constness
,
Abi
,
Visibility
),
ItemFn
(
Name
,
&
'a
Generics
,
Unsafety
,
Constness
,
Abi
,
Visibility
),
/// fn foo(&self)
/// fn foo(&self)
Method
(
Ident
,
&
'a
MethodSig
,
Option
<
Visibility
>
),
Method
(
Name
,
&
'a
MethodSig
,
Option
<
Visibility
>
),
/// |x, y| ...
/// |x, y| ...
/// proc(x, y) ...
/// proc(x, y) ...
...
@@ -57,9 +57,6 @@ pub trait Visitor<'v> : Sized {
...
@@ -57,9 +57,6 @@ pub trait Visitor<'v> : Sized {
fn
visit_name
(
&
mut
self
,
_
span
:
Span
,
_
name
:
Name
)
{
fn
visit_name
(
&
mut
self
,
_
span
:
Span
,
_
name
:
Name
)
{
// Nothing to do.
// Nothing to do.
}
}
fn
visit_ident
(
&
mut
self
,
span
:
Span
,
ident
:
Ident
)
{
self
.visit_name
(
span
,
ident
.name
);
}
fn
visit_mod
(
&
mut
self
,
m
:
&
'v
Mod
,
_
s
:
Span
,
_
n
:
NodeId
)
{
walk_mod
(
self
,
m
)
}
fn
visit_mod
(
&
mut
self
,
m
:
&
'v
Mod
,
_
s
:
Span
,
_
n
:
NodeId
)
{
walk_mod
(
self
,
m
)
}
fn
visit_foreign_item
(
&
mut
self
,
i
:
&
'v
ForeignItem
)
{
walk_foreign_item
(
self
,
i
)
}
fn
visit_foreign_item
(
&
mut
self
,
i
:
&
'v
ForeignItem
)
{
walk_foreign_item
(
self
,
i
)
}
fn
visit_item
(
&
mut
self
,
i
:
&
'v
Item
)
{
walk_item
(
self
,
i
)
}
fn
visit_item
(
&
mut
self
,
i
:
&
'v
Item
)
{
walk_item
(
self
,
i
)
}
...
@@ -85,7 +82,7 @@ fn visit_ty_param_bound(&mut self, bounds: &'v TyParamBound) {
...
@@ -85,7 +82,7 @@ fn visit_ty_param_bound(&mut self, bounds: &'v TyParamBound) {
fn
visit_poly_trait_ref
(
&
mut
self
,
t
:
&
'v
PolyTraitRef
,
m
:
&
'v
TraitBoundModifier
)
{
fn
visit_poly_trait_ref
(
&
mut
self
,
t
:
&
'v
PolyTraitRef
,
m
:
&
'v
TraitBoundModifier
)
{
walk_poly_trait_ref
(
self
,
t
,
m
)
walk_poly_trait_ref
(
self
,
t
,
m
)
}
}
fn
visit_struct_def
(
&
mut
self
,
s
:
&
'v
StructDef
,
_
:
Ident
,
_
:
&
'v
Generics
,
_
:
NodeId
)
{
fn
visit_struct_def
(
&
mut
self
,
s
:
&
'v
StructDef
,
_
:
Name
,
_
:
&
'v
Generics
,
_
:
NodeId
)
{
walk_struct_def
(
self
,
s
)
walk_struct_def
(
self
,
s
)
}
}
fn
visit_struct_field
(
&
mut
self
,
s
:
&
'v
StructField
)
{
walk_struct_field
(
self
,
s
)
}
fn
visit_struct_field
(
&
mut
self
,
s
:
&
'v
StructField
)
{
walk_struct_field
(
self
,
s
)
}
...
@@ -201,12 +198,13 @@ pub fn walk_trait_ref<'v,V>(visitor: &mut V,
...
@@ -201,12 +198,13 @@ pub fn walk_trait_ref<'v,V>(visitor: &mut V,
}
}
pub
fn
walk_item
<
'v
,
V
:
Visitor
<
'v
>>
(
visitor
:
&
mut
V
,
item
:
&
'v
Item
)
{
pub
fn
walk_item
<
'v
,
V
:
Visitor
<
'v
>>
(
visitor
:
&
mut
V
,
item
:
&
'v
Item
)
{
visitor
.visit_
ident
(
item
.span
,
item
.ident
);
visitor
.visit_
name
(
item
.span
,
item
.ident.name
);
match
item
.node
{
match
item
.node
{
ItemExternCrate
(
..
)
=>
{}
ItemExternCrate
(
..
)
=>
{}
ItemUse
(
ref
vp
)
=>
{
ItemUse
(
ref
vp
)
=>
{
match
vp
.node
{
match
vp
.node
{
ViewPathSimple
(
_
ident
,
ref
path
)
=>
{
ViewPathSimple
(
name
,
ref
path
)
=>
{
visitor
.visit_name
(
vp
.span
,
name
);
visitor
.visit_path
(
path
,
item
.id
);
visitor
.visit_path
(
path
,
item
.id
);
}
}
ViewPathGlob
(
ref
path
)
=>
{
ViewPathGlob
(
ref
path
)
=>
{
...
@@ -229,7 +227,7 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) {
...
@@ -229,7 +227,7 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) {
visitor
.visit_expr
(
&**
expr
);
visitor
.visit_expr
(
&**
expr
);
}
}
ItemFn
(
ref
declaration
,
unsafety
,
constness
,
abi
,
ref
generics
,
ref
body
)
=>
{
ItemFn
(
ref
declaration
,
unsafety
,
constness
,
abi
,
ref
generics
,
ref
body
)
=>
{
visitor
.visit_fn
(
FnKind
::
ItemFn
(
item
.ident
,
generics
,
unsafety
,
visitor
.visit_fn
(
FnKind
::
ItemFn
(
item
.ident
.name
,
generics
,
unsafety
,
constness
,
abi
,
item
.vis
),
constness
,
abi
,
item
.vis
),
&**
declaration
,
&**
declaration
,
&**
body
,
&**
body
,
...
@@ -273,7 +271,7 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) {
...
@@ -273,7 +271,7 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) {
ItemStruct
(
ref
struct_definition
,
ref
generics
)
=>
{
ItemStruct
(
ref
struct_definition
,
ref
generics
)
=>
{
visitor
.visit_generics
(
generics
);
visitor
.visit_generics
(
generics
);
visitor
.visit_struct_def
(
&**
struct_definition
,
visitor
.visit_struct_def
(
&**
struct_definition
,
item
.ident
,
item
.ident
.name
,
generics
,
generics
,
item
.id
)
item
.id
)
}
}
...
@@ -301,7 +299,7 @@ pub fn walk_enum_def<'v, V: Visitor<'v>>(visitor: &mut V,
...
@@ -301,7 +299,7 @@ pub fn walk_enum_def<'v, V: Visitor<'v>>(visitor: &mut V,
pub
fn
walk_variant
<
'v
,
V
:
Visitor
<
'v
>>
(
visitor
:
&
mut
V
,
pub
fn
walk_variant
<
'v
,
V
:
Visitor
<
'v
>>
(
visitor
:
&
mut
V
,
variant
:
&
'v
Variant
,
variant
:
&
'v
Variant
,
generics
:
&
'v
Generics
)
{
generics
:
&
'v
Generics
)
{
visitor
.visit_
ident
(
variant
.span
,
variant
.nod
e.name
);
visitor
.visit_
name
(
variant
.span
,
variant
.node.nam
e.name
);
match
variant
.node.kind
{
match
variant
.node.kind
{
TupleVariantKind
(
ref
variant_arguments
)
=>
{
TupleVariantKind
(
ref
variant_arguments
)
=>
{
...
@@ -311,7 +309,7 @@ pub fn walk_variant<'v, V: Visitor<'v>>(visitor: &mut V,
...
@@ -311,7 +309,7 @@ pub fn walk_variant<'v, V: Visitor<'v>>(visitor: &mut V,
}
}
StructVariantKind
(
ref
struct_definition
)
=>
{
StructVariantKind
(
ref
struct_definition
)
=>
{
visitor
.visit_struct_def
(
&**
struct_definition
,
visitor
.visit_struct_def
(
&**
struct_definition
,
variant
.node.name
,
variant
.node.name
.name
,
generics
,
generics
,
variant
.node.id
)
variant
.node.id
)
}
}
...
@@ -411,7 +409,7 @@ pub fn walk_path_list_item<'v, V: Visitor<'v>>(visitor: &mut V, prefix: &'v Path
...
@@ -411,7 +409,7 @@ pub fn walk_path_list_item<'v, V: Visitor<'v>>(visitor: &mut V, prefix: &'v Path
pub
fn
walk_path_segment
<
'v
,
V
:
Visitor
<
'v
>>
(
visitor
:
&
mut
V
,
pub
fn
walk_path_segment
<
'v
,
V
:
Visitor
<
'v
>>
(
visitor
:
&
mut
V
,
path_span
:
Span
,
path_span
:
Span
,
segment
:
&
'v
PathSegment
)
{
segment
:
&
'v
PathSegment
)
{
visitor
.visit_
ident
(
path_span
,
segment
.identifier
);
visitor
.visit_
name
(
path_span
,
segment
.identifier.name
);
visitor
.visit_path_parameters
(
path_span
,
&
segment
.parameters
);
visitor
.visit_path_parameters
(
path_span
,
&
segment
.parameters
);
}
}
...
@@ -443,7 +441,7 @@ pub fn walk_path_parameters<'v, V: Visitor<'v>>(visitor: &mut V,
...
@@ -443,7 +441,7 @@ pub fn walk_path_parameters<'v, V: Visitor<'v>>(visitor: &mut V,
pub
fn
walk_assoc_type_binding
<
'v
,
V
:
Visitor
<
'v
>>
(
visitor
:
&
mut
V
,
pub
fn
walk_assoc_type_binding
<
'v
,
V
:
Visitor
<
'v
>>
(
visitor
:
&
mut
V
,
type_binding
:
&
'v
TypeBinding
)
{
type_binding
:
&
'v
TypeBinding
)
{
visitor
.visit_
ident
(
type_binding
.span
,
type_binding
.ident
);
visitor
.visit_
name
(
type_binding
.span
,
type_binding
.ident.name
);
visitor
.visit_ty
(
&*
type_binding
.ty
);
visitor
.visit_ty
(
&*
type_binding
.ty
);
}
}
...
@@ -477,7 +475,7 @@ pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat) {
...
@@ -477,7 +475,7 @@ pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat) {
visitor
.visit_pat
(
&**
subpattern
)
visitor
.visit_pat
(
&**
subpattern
)
}
}
PatIdent
(
_
,
ref
pth1
,
ref
optional_subpattern
)
=>
{
PatIdent
(
_
,
ref
pth1
,
ref
optional_subpattern
)
=>
{
visitor
.visit_
ident
(
pth1
.span
,
pth1
.nod
e
);
visitor
.visit_
name
(
pth1
.span
,
pth1
.node.nam
e
);
match
*
optional_subpattern
{
match
*
optional_subpattern
{
None
=>
{}
None
=>
{}
Some
(
ref
subpattern
)
=>
visitor
.visit_pat
(
&**
subpattern
),
Some
(
ref
subpattern
)
=>
visitor
.visit_pat
(
&**
subpattern
),
...
@@ -505,7 +503,7 @@ pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat) {
...
@@ -505,7 +503,7 @@ pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat) {
pub
fn
walk_foreign_item
<
'v
,
V
:
Visitor
<
'v
>>
(
visitor
:
&
mut
V
,
pub
fn
walk_foreign_item
<
'v
,
V
:
Visitor
<
'v
>>
(
visitor
:
&
mut
V
,
foreign_item
:
&
'v
ForeignItem
)
{
foreign_item
:
&
'v
ForeignItem
)
{
visitor
.visit_
ident
(
foreign_item
.span
,
foreign_item
.ident
);
visitor
.visit_
name
(
foreign_item
.span
,
foreign_item
.ident.name
);
match
foreign_item
.node
{
match
foreign_item
.node
{
ForeignItemFn
(
ref
function_declaration
,
ref
generics
)
=>
{
ForeignItemFn
(
ref
function_declaration
,
ref
generics
)
=>
{
...
@@ -541,7 +539,7 @@ pub fn walk_ty_param_bound<'v, V: Visitor<'v>>(visitor: &mut V,
...
@@ -541,7 +539,7 @@ pub fn walk_ty_param_bound<'v, V: Visitor<'v>>(visitor: &mut V,
pub
fn
walk_generics
<
'v
,
V
:
Visitor
<
'v
>>
(
visitor
:
&
mut
V
,
generics
:
&
'v
Generics
)
{
pub
fn
walk_generics
<
'v
,
V
:
Visitor
<
'v
>>
(
visitor
:
&
mut
V
,
generics
:
&
'v
Generics
)
{
for
param
in
generics
.ty_params
.iter
()
{
for
param
in
generics
.ty_params
.iter
()
{
visitor
.visit_
ident
(
param
.span
,
param
.ident
);
visitor
.visit_
name
(
param
.span
,
param
.ident.name
);
walk_ty_param_bounds_helper
(
visitor
,
&
param
.bounds
);
walk_ty_param_bounds_helper
(
visitor
,
&
param
.bounds
);
walk_ty_opt
(
visitor
,
&
param
.default
);
walk_ty_opt
(
visitor
,
&
param
.default
);
}
}
...
@@ -613,7 +611,7 @@ pub fn walk_fn<'v, V: Visitor<'v>>(visitor: &mut V,
...
@@ -613,7 +611,7 @@ pub fn walk_fn<'v, V: Visitor<'v>>(visitor: &mut V,
}
}
pub
fn
walk_trait_item
<
'v
,
V
:
Visitor
<
'v
>>
(
visitor
:
&
mut
V
,
trait_item
:
&
'v
TraitItem
)
{
pub
fn
walk_trait_item
<
'v
,
V
:
Visitor
<
'v
>>
(
visitor
:
&
mut
V
,
trait_item
:
&
'v
TraitItem
)
{
visitor
.visit_
ident
(
trait_item
.span
,
trait_item
.ident
);
visitor
.visit_
name
(
trait_item
.span
,
trait_item
.ident.name
);
for
attr
in
&
trait_item
.attrs
{
for
attr
in
&
trait_item
.attrs
{
visitor
.visit_attribute
(
attr
);
visitor
.visit_attribute
(
attr
);
}
}
...
@@ -630,7 +628,7 @@ pub fn walk_trait_item<'v, V: Visitor<'v>>(visitor: &mut V, trait_item: &'v Trai
...
@@ -630,7 +628,7 @@ pub fn walk_trait_item<'v, V: Visitor<'v>>(visitor: &mut V, trait_item: &'v Trai
walk_fn_decl
(
visitor
,
&
sig
.decl
);
walk_fn_decl
(
visitor
,
&
sig
.decl
);
}
}
MethodTraitItem
(
ref
sig
,
Some
(
ref
body
))
=>
{
MethodTraitItem
(
ref
sig
,
Some
(
ref
body
))
=>
{
visitor
.visit_fn
(
FnKind
::
Method
(
trait_item
.ident
,
sig
,
None
),
&
sig
.decl
,
visitor
.visit_fn
(
FnKind
::
Method
(
trait_item
.ident
.name
,
sig
,
None
),
&
sig
.decl
,
body
,
trait_item
.span
,
trait_item
.id
);
body
,
trait_item
.span
,
trait_item
.id
);
}
}
TypeTraitItem
(
ref
bounds
,
ref
default
)
=>
{
TypeTraitItem
(
ref
bounds
,
ref
default
)
=>
{
...
@@ -641,7 +639,7 @@ pub fn walk_trait_item<'v, V: Visitor<'v>>(visitor: &mut V, trait_item: &'v Trai
...
@@ -641,7 +639,7 @@ pub fn walk_trait_item<'v, V: Visitor<'v>>(visitor: &mut V, trait_item: &'v Trai
}
}
pub
fn
walk_impl_item
<
'v
,
V
:
Visitor
<
'v
>>
(
visitor
:
&
mut
V
,
impl_item
:
&
'v
ImplItem
)
{
pub
fn
walk_impl_item
<
'v
,
V
:
Visitor
<
'v
>>
(
visitor
:
&
mut
V
,
impl_item
:
&
'v
ImplItem
)
{
visitor
.visit_
ident
(
impl_item
.span
,
impl_item
.ident
);
visitor
.visit_
name
(
impl_item
.span
,
impl_item
.ident.name
);
for
attr
in
&
impl_item
.attrs
{
for
attr
in
&
impl_item
.attrs
{
visitor
.visit_attribute
(
attr
);
visitor
.visit_attribute
(
attr
);
}
}
...
@@ -651,8 +649,8 @@ pub fn walk_impl_item<'v, V: Visitor<'v>>(visitor: &mut V, impl_item: &'v ImplIt
...
@@ -651,8 +649,8 @@ pub fn walk_impl_item<'v, V: Visitor<'v>>(visitor: &mut V, impl_item: &'v ImplIt
visitor
.visit_expr
(
expr
);
visitor
.visit_expr
(
expr
);
}
}
MethodImplItem
(
ref
sig
,
ref
body
)
=>
{
MethodImplItem
(
ref
sig
,
ref
body
)
=>
{
visitor
.visit_fn
(
FnKind
::
Method
(
impl_item
.ident
,
sig
,
Some
(
impl_item
.vis
)),
&
sig
.decl
,
visitor
.visit_fn
(
FnKind
::
Method
(
impl_item
.ident
.name
,
sig
,
Some
(
impl_item
.vis
))
,
body
,
impl_item
.span
,
impl_item
.id
);
&
sig
.decl
,
body
,
impl_item
.span
,
impl_item
.id
);
}
}
TypeImplItem
(
ref
ty
)
=>
{
TypeImplItem
(
ref
ty
)
=>
{
visitor
.visit_ty
(
ty
);
visitor
.visit_ty
(
ty
);
...
@@ -670,7 +668,7 @@ pub fn walk_struct_def<'v, V: Visitor<'v>>(visitor: &mut V,
...
@@ -670,7 +668,7 @@ pub fn walk_struct_def<'v, V: Visitor<'v>>(visitor: &mut V,
pub
fn
walk_struct_field
<
'v
,
V
:
Visitor
<
'v
>>
(
visitor
:
&
mut
V
,
pub
fn
walk_struct_field
<
'v
,
V
:
Visitor
<
'v
>>
(
visitor
:
&
mut
V
,
struct_field
:
&
'v
StructField
)
{
struct_field
:
&
'v
StructField
)
{
if
let
NamedField
(
name
,
_
)
=
struct_field
.node.kind
{
if
let
NamedField
(
name
,
_
)
=
struct_field
.node.kind
{
visitor
.visit_
ident
(
struct_field
.span
,
name
);
visitor
.visit_
name
(
struct_field
.span
,
name
.
name
);
}
}
visitor
.visit_ty
(
&*
struct_field
.node.ty
);
visitor
.visit_ty
(
&*
struct_field
.node.ty
);
...
...
src/librustc_lint/builtin.rs
浏览文件 @
ae77dbb8
...
@@ -1081,12 +1081,12 @@ fn exit_lint_attrs(&mut self, _: &LateContext, _: &[ast::Attribute]) {
...
@@ -1081,12 +1081,12 @@ fn exit_lint_attrs(&mut self, _: &LateContext, _: &[ast::Attribute]) {
}
}
fn
check_struct_def
(
&
mut
self
,
_
:
&
LateContext
,
_
:
&
hir
::
StructDef
,
fn
check_struct_def
(
&
mut
self
,
_
:
&
LateContext
,
_
:
&
hir
::
StructDef
,
_
:
ast
::
Ident
,
_
:
&
hir
::
Generics
,
id
:
ast
::
NodeId
)
{
_
:
ast
::
Name
,
_
:
&
hir
::
Generics
,
id
:
ast
::
NodeId
)
{
self
.struct_def_stack
.push
(
id
);
self
.struct_def_stack
.push
(
id
);
}
}
fn
check_struct_def_post
(
&
mut
self
,
_
:
&
LateContext
,
_
:
&
hir
::
StructDef
,
fn
check_struct_def_post
(
&
mut
self
,
_
:
&
LateContext
,
_
:
&
hir
::
StructDef
,
_
:
ast
::
Ident
,
_
:
&
hir
::
Generics
,
id
:
ast
::
NodeId
)
{
_
:
ast
::
Name
,
_
:
&
hir
::
Generics
,
id
:
ast
::
NodeId
)
{
let
popped
=
self
.struct_def_stack
.pop
()
.expect
(
"empty struct_def_stack"
);
let
popped
=
self
.struct_def_stack
.pop
()
.expect
(
"empty struct_def_stack"
);
assert
!
(
popped
==
id
);
assert
!
(
popped
==
id
);
}
}
...
...
src/librustc_privacy/lib.rs
浏览文件 @
ae77dbb8
...
@@ -128,7 +128,7 @@ fn visit_impl_item(&mut self, ii: &'v hir::ImplItem) {
...
@@ -128,7 +128,7 @@ fn visit_impl_item(&mut self, ii: &'v hir::ImplItem) {
visit
::
walk_impl_item
(
self
,
ii
);
visit
::
walk_impl_item
(
self
,
ii
);
}
}
fn
visit_struct_def
(
&
mut
self
,
s
:
&
hir
::
StructDef
,
_
:
ast
::
Ident
,
fn
visit_struct_def
(
&
mut
self
,
s
:
&
hir
::
StructDef
,
_
:
ast
::
Name
,
_
:
&
'v
hir
::
Generics
,
n
:
ast
::
NodeId
)
{
_
:
&
'v
hir
::
Generics
,
n
:
ast
::
NodeId
)
{
// Struct constructors are parented to their struct definitions because
// Struct constructors are parented to their struct definitions because
// they essentially are the struct definitions.
// they essentially are the struct definitions.
...
...
src/librustc_resolve/lib.rs
浏览文件 @
ae77dbb8
...
@@ -509,7 +509,7 @@ fn visit_variant(&mut self, variant: &hir::Variant, generics: &Generics) {
...
@@ -509,7 +509,7 @@ fn visit_variant(&mut self, variant: &hir::Variant, generics: &Generics) {
}
}
hir
::
StructVariantKind
(
ref
struct_definition
)
=>
{
hir
::
StructVariantKind
(
ref
struct_definition
)
=>
{
self
.visit_struct_def
(
&**
struct_definition
,
self
.visit_struct_def
(
&**
struct_definition
,
variant
.node.name
,
variant
.node.name
.name
,
generics
,
generics
,
variant
.node.id
);
variant
.node.id
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录