Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
4744d568
R
Rust
项目概览
int
/
Rust
11 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
4744d568
编写于
9月 29, 2015
作者:
V
Vadim Petrochenkov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fill in some missing parts in the default HIR visitor
上级
eedb9510
变更
15
展开全部
隐藏空白更改
内联
并排
Showing
15 changed file
with
291 addition
and
370 deletion
+291
-370
src/librustc/front/map/mod.rs
src/librustc/front/map/mod.rs
+2
-2
src/librustc/lint/context.rs
src/librustc/lint/context.rs
+2
-6
src/librustc/lint/mod.rs
src/librustc/lint/mod.rs
+1
-2
src/librustc/metadata/creader.rs
src/librustc/metadata/creader.rs
+6
-0
src/librustc/middle/region.rs
src/librustc/middle/region.rs
+1
-1
src/librustc/middle/resolve_lifetime.rs
src/librustc/middle/resolve_lifetime.rs
+11
-12
src/librustc_back/svh.rs
src/librustc_back/svh.rs
+3
-15
src/librustc_front/hir.rs
src/librustc_front/hir.rs
+7
-0
src/librustc_front/util.rs
src/librustc_front/util.rs
+2
-2
src/librustc_front/visit.rs
src/librustc_front/visit.rs
+220
-314
src/librustc_resolve/lib.rs
src/librustc_resolve/lib.rs
+4
-4
src/librustc_trans/trans/base.rs
src/librustc_trans/trans/base.rs
+1
-1
src/librustc_typeck/check/mod.rs
src/librustc_typeck/check/mod.rs
+9
-0
src/librustc_typeck/check/writeback.rs
src/librustc_typeck/check/writeback.rs
+4
-0
src/libsyntax/visit.rs
src/libsyntax/visit.rs
+18
-11
未找到文件。
src/librustc/front/map/mod.rs
浏览文件 @
4744d568
...
...
@@ -912,12 +912,12 @@ fn visit_block(&mut self, block: &'ast Block) {
self
.parent_node
=
parent_node
;
}
fn
visit_lifetime
_ref
(
&
mut
self
,
lifetime
:
&
'ast
Lifetime
)
{
fn
visit_lifetime
(
&
mut
self
,
lifetime
:
&
'ast
Lifetime
)
{
self
.insert
(
lifetime
.id
,
NodeLifetime
(
lifetime
));
}
fn
visit_lifetime_def
(
&
mut
self
,
def
:
&
'ast
LifetimeDef
)
{
self
.visit_lifetime
_ref
(
&
def
.lifetime
);
self
.visit_lifetime
(
&
def
.lifetime
);
}
}
...
...
src/librustc/lint/context.rs
浏览文件 @
4744d568
...
...
@@ -745,12 +745,8 @@ fn visit_impl_item(&mut self, impl_item: &hir::ImplItem) {
});
}
fn
visit_opt_lifetime_ref
(
&
mut
self
,
sp
:
Span
,
lt
:
&
Option
<
hir
::
Lifetime
>
)
{
run_lints!
(
self
,
check_opt_lifetime_ref
,
late_passes
,
sp
,
lt
);
}
fn
visit_lifetime_ref
(
&
mut
self
,
lt
:
&
hir
::
Lifetime
)
{
run_lints!
(
self
,
check_lifetime_ref
,
late_passes
,
lt
);
fn
visit_lifetime
(
&
mut
self
,
lt
:
&
hir
::
Lifetime
)
{
run_lints!
(
self
,
check_lifetime
,
late_passes
,
lt
);
}
fn
visit_lifetime_def
(
&
mut
self
,
lt
:
&
hir
::
LifetimeDef
)
{
...
...
src/librustc/lint/mod.rs
浏览文件 @
4744d568
...
...
@@ -156,8 +156,7 @@ fn check_struct_def_post(&mut self, _: &LateContext,
fn
check_struct_field
(
&
mut
self
,
_
:
&
LateContext
,
_
:
&
hir
::
StructField
)
{
}
fn
check_variant
(
&
mut
self
,
_
:
&
LateContext
,
_
:
&
hir
::
Variant
,
_
:
&
hir
::
Generics
)
{
}
fn
check_variant_post
(
&
mut
self
,
_
:
&
LateContext
,
_
:
&
hir
::
Variant
,
_
:
&
hir
::
Generics
)
{
}
fn
check_opt_lifetime_ref
(
&
mut
self
,
_
:
&
LateContext
,
_
:
Span
,
_
:
&
Option
<
hir
::
Lifetime
>
)
{
}
fn
check_lifetime_ref
(
&
mut
self
,
_
:
&
LateContext
,
_
:
&
hir
::
Lifetime
)
{
}
fn
check_lifetime
(
&
mut
self
,
_
:
&
LateContext
,
_
:
&
hir
::
Lifetime
)
{
}
fn
check_lifetime_def
(
&
mut
self
,
_
:
&
LateContext
,
_
:
&
hir
::
LifetimeDef
)
{
}
fn
check_explicit_self
(
&
mut
self
,
_
:
&
LateContext
,
_
:
&
hir
::
ExplicitSelf
)
{
}
fn
check_path
(
&
mut
self
,
_
:
&
LateContext
,
_
:
&
hir
::
Path
,
_
:
ast
::
NodeId
)
{
}
...
...
src/librustc/metadata/creader.rs
浏览文件 @
4744d568
...
...
@@ -481,6 +481,12 @@ pub fn read_exported_macros(&mut self, item: &ast::Item) -> Vec<ast::MacroDef> {
};
let
span
=
mk_sp
(
lo
,
p
.last_span.hi
);
p
.abort_if_errors
();
// Mark the attrs as used
for
attr
in
&
attrs
{
attr
::
mark_used
(
attr
);
}
macros
.push
(
ast
::
MacroDef
{
ident
:
ast
::
Ident
::
with_empty_ctxt
(
name
),
attrs
:
attrs
,
...
...
src/librustc/middle/region.rs
浏览文件 @
4744d568
...
...
@@ -705,7 +705,7 @@ fn resolve_block(visitor: &mut RegionResolutionVisitor, blk: &hir::Block) {
}
visitor
.visit_stmt
(
&**
statement
)
}
visit
::
walk_expr_opt
(
visitor
,
&
blk
.expr
)
walk_list!
(
visitor
,
visit_expr
,
&
blk
.expr
);
}
visitor
.cx
=
prev_cx
;
...
...
src/librustc/middle/resolve_lifetime.rs
浏览文件 @
4744d568
...
...
@@ -195,7 +195,6 @@ fn visit_fn(&mut self, fk: FnKind<'v>, fd: &'v hir::FnDecl,
fn
visit_ty
(
&
mut
self
,
ty
:
&
hir
::
Ty
)
{
match
ty
.node
{
hir
::
TyBareFn
(
ref
c
)
=>
{
visit
::
walk_lifetime_decls_helper
(
self
,
&
c
.lifetimes
);
self
.with
(
LateScope
(
&
c
.lifetimes
,
self
.scope
),
|
old_scope
,
this
|
{
// a bare fn has no bounds, so everything
// contained within is scoped within its binder.
...
...
@@ -245,7 +244,7 @@ fn visit_block(&mut self, b: &hir::Block) {
|
_
,
this
|
visit
::
walk_block
(
this
,
b
));
}
fn
visit_lifetime
_ref
(
&
mut
self
,
lifetime_ref
:
&
hir
::
Lifetime
)
{
fn
visit_lifetime
(
&
mut
self
,
lifetime_ref
:
&
hir
::
Lifetime
)
{
if
lifetime_ref
.name
==
special_idents
::
static_lifetime
.name
{
self
.insert_lifetime
(
lifetime_ref
,
DefStaticRegion
);
return
;
...
...
@@ -255,7 +254,7 @@ fn visit_lifetime_ref(&mut self, lifetime_ref: &hir::Lifetime) {
fn
visit_generics
(
&
mut
self
,
generics
:
&
hir
::
Generics
)
{
for
ty_param
in
generics
.ty_params
.iter
()
{
visit
::
walk_ty_param_bounds_helper
(
self
,
&
ty_param
.bounds
);
walk_list!
(
self
,
visit_ty_param_bound
,
&
ty_param
.bounds
);
match
ty_param
.default
{
Some
(
ref
ty
)
=>
self
.visit_ty
(
&**
ty
),
None
=>
{}
...
...
@@ -273,22 +272,22 @@ fn visit_generics(&mut self, generics: &hir::Generics) {
|
old_scope
,
this
|
{
this
.check_lifetime_defs
(
old_scope
,
bound_lifetimes
);
this
.visit_ty
(
&**
bounded_ty
);
visit
::
walk_ty_param_bounds_helper
(
this
,
bounds
);
walk_list!
(
this
,
visit_ty_param_bound
,
bounds
);
});
self
.trait_ref_hack
=
false
;
result
}
else
{
self
.visit_ty
(
&**
bounded_ty
);
visit
::
walk_ty_param_bounds_helper
(
self
,
bounds
);
walk_list!
(
self
,
visit_ty_param_bound
,
bounds
);
}
}
&
hir
::
WherePredicate
::
RegionPredicate
(
hir
::
WhereRegionPredicate
{
ref
lifetime
,
ref
bounds
,
..
})
=>
{
self
.visit_lifetime
_ref
(
lifetime
);
self
.visit_lifetime
(
lifetime
);
for
bound
in
bounds
{
self
.visit_lifetime
_ref
(
bound
);
self
.visit_lifetime
(
bound
);
}
}
&
hir
::
WherePredicate
::
EqPredicate
(
hir
::
WhereEqPredicate
{
id
,
...
...
@@ -799,7 +798,7 @@ fn early_bound_lifetime_names(generics: &hir::Generics) -> Vec<ast::Name> {
FreeLifetimeCollector
{
early_bound
:
&
mut
early_bound
,
late_bound
:
&
mut
late_bound
};
for
ty_param
in
generics
.ty_params
.iter
()
{
visit
::
walk_ty_param_bounds_helper
(
&
mut
collector
,
&
ty_param
.bounds
);
walk_list!
(
&
mut
collector
,
visit_ty_param_bound
,
&
ty_param
.bounds
);
}
for
predicate
in
&
generics
.where_clause.predicates
{
match
predicate
{
...
...
@@ -807,15 +806,15 @@ fn early_bound_lifetime_names(generics: &hir::Generics) -> Vec<ast::Name> {
ref
bounded_ty
,
..
})
=>
{
collector
.visit_ty
(
&**
bounded_ty
);
visit
::
walk_ty_param_bounds_helper
(
&
mut
collector
,
bounds
);
walk_list!
(
&
mut
collector
,
visit_ty_param_bound
,
bounds
);
}
&
hir
::
WherePredicate
::
RegionPredicate
(
hir
::
WhereRegionPredicate
{
ref
lifetime
,
ref
bounds
,
..
})
=>
{
collector
.visit_lifetime
_ref
(
lifetime
);
collector
.visit_lifetime
(
lifetime
);
for
bound
in
bounds
{
collector
.visit_lifetime
_ref
(
bound
);
collector
.visit_lifetime
(
bound
);
}
}
&
hir
::
WherePredicate
::
EqPredicate
(
_
)
=>
unimplemented!
()
...
...
@@ -843,7 +842,7 @@ struct FreeLifetimeCollector<'a> {
}
impl
<
'a
,
'v
>
Visitor
<
'v
>
for
FreeLifetimeCollector
<
'a
>
{
fn
visit_lifetime
_ref
(
&
mut
self
,
lifetime_ref
:
&
hir
::
Lifetime
)
{
fn
visit_lifetime
(
&
mut
self
,
lifetime_ref
:
&
hir
::
Lifetime
)
{
shuffle
(
self
.early_bound
,
self
.late_bound
,
lifetime_ref
.name
);
}
...
...
src/librustc_back/svh.rs
浏览文件 @
4744d568
...
...
@@ -177,7 +177,7 @@ enum SawAbiComponent<'a> {
SawIdent
(
token
::
InternedString
),
SawStructDef
(
token
::
InternedString
),
SawLifetime
Ref
(
token
::
InternedString
),
SawLifetime
(
token
::
InternedString
),
SawLifetimeDef
(
token
::
InternedString
),
SawMod
,
...
...
@@ -193,7 +193,6 @@ enum SawAbiComponent<'a> {
SawVariant
,
SawExplicitSelf
,
SawPath
,
SawOptLifetimeRef
,
SawBlock
,
SawPat
,
SawLocal
,
...
...
@@ -316,17 +315,6 @@ fn visit_variant(&mut self, v: &Variant, g: &Generics) {
visit
::
walk_variant
(
self
,
v
,
g
)
}
fn
visit_opt_lifetime_ref
(
&
mut
self
,
_
:
Span
,
l
:
&
Option
<
Lifetime
>
)
{
SawOptLifetimeRef
.hash
(
self
.st
);
// (This is a strange method in the visitor trait, in that
// it does not expose a walk function to do the subroutine
// calls.)
match
*
l
{
Some
(
ref
l
)
=>
self
.visit_lifetime_ref
(
l
),
None
=>
()
}
}
// All of the remaining methods just record (in the hash
// SipHasher) that the visitor saw that particular variant
// (with its payload), and continue walking as the default
...
...
@@ -345,8 +333,8 @@ fn visit_name(&mut self, _: Span, name: Name) {
SawIdent
(
name
.as_str
())
.hash
(
self
.st
);
}
fn
visit_lifetime
_ref
(
&
mut
self
,
l
:
&
Lifetime
)
{
SawLifetime
Ref
(
l
.name
.as_str
())
.hash
(
self
.st
);
fn
visit_lifetime
(
&
mut
self
,
l
:
&
Lifetime
)
{
SawLifetime
(
l
.name
.as_str
())
.hash
(
self
.st
);
}
fn
visit_lifetime_def
(
&
mut
self
,
l
:
&
LifetimeDef
)
{
...
...
src/librustc_front/hir.rs
浏览文件 @
4744d568
...
...
@@ -1054,6 +1054,13 @@ pub fn id(&self) -> NodeId {
}
}
pub
fn
name
(
&
self
)
->
Option
<
Name
>
{
match
*
self
{
PathListIdent
{
name
,
..
}
=>
Some
(
name
),
PathListMod
{
..
}
=>
None
,
}
}
pub
fn
rename
(
&
self
)
->
Option
<
Name
>
{
match
*
self
{
PathListIdent
{
rename
,
..
}
|
PathListMod
{
rename
,
..
}
=>
rename
...
...
src/librustc_front/util.rs
浏览文件 @
4744d568
...
...
@@ -303,12 +303,12 @@ fn visit_impl_item(&mut self, ii: &hir::ImplItem) {
visit
::
walk_impl_item
(
self
,
ii
);
}
fn
visit_lifetime
_ref
(
&
mut
self
,
lifetime
:
&
Lifetime
)
{
fn
visit_lifetime
(
&
mut
self
,
lifetime
:
&
Lifetime
)
{
self
.operation
.visit_id
(
lifetime
.id
);
}
fn
visit_lifetime_def
(
&
mut
self
,
def
:
&
LifetimeDef
)
{
self
.visit_lifetime
_ref
(
&
def
.lifetime
);
self
.visit_lifetime
(
&
def
.lifetime
);
}
fn
visit_trait_ref
(
&
mut
self
,
trait_ref
:
&
TraitRef
)
{
...
...
src/librustc_front/visit.rs
浏览文件 @
4744d568
此差异已折叠。
点击以展开。
src/librustc_resolve/lib.rs
浏览文件 @
4744d568
...
...
@@ -2158,7 +2158,7 @@ fn resolve_item(&mut self, item: &Item) {
|
this
|
{
this
.with_self_rib
(
DefSelfTy
(
Some
(
DefId
::
local
(
item
.id
)),
None
),
|
this
|
{
this
.visit_generics
(
generics
);
visit
::
walk_ty_param_bounds_helper
(
this
,
bounds
);
walk_list!
(
this
,
visit_ty_param_bound
,
bounds
);
for
trait_item
in
trait_items
{
match
trait_item
.node
{
...
...
@@ -2542,10 +2542,10 @@ fn check_trait_item<F>(&self, name: Name, span: Span, err: F)
fn
resolve_local
(
&
mut
self
,
local
:
&
Local
)
{
// Resolve the type.
visit
::
walk_ty_opt
(
self
,
&
local
.ty
);
walk_list!
(
self
,
visit_ty
,
&
local
.ty
);
// Resolve the initializer.
visit
::
walk_expr_opt
(
self
,
&
local
.init
);
walk_list!
(
self
,
visit_expr
,
&
local
.init
);
// Resolve the pattern.
self
.resolve_pattern
(
&*
local
.pat
,
...
...
@@ -2622,7 +2622,7 @@ fn resolve_arm(&mut self, arm: &Arm) {
// pat_idents are variants
self
.check_consistent_bindings
(
arm
);
visit
::
walk_expr_opt
(
self
,
&
arm
.guard
);
walk_list!
(
self
,
visit_expr
,
&
arm
.guard
);
self
.visit_expr
(
&*
arm
.body
);
if
!
self
.resolved
{
...
...
src/librustc_trans/trans/base.rs
浏览文件 @
4744d568
...
...
@@ -1167,7 +1167,7 @@ fn has_nested_returns(tcx: &ty::ctxt, cfg: &cfg::CFG, blk_id: ast::NodeId) -> bo
}
Some
(
hir_map
::
NodeBlock
(
blk
))
if
blk
.id
==
blk_id
=>
{
let
mut
visitor
=
FindNestedReturn
::
new
();
visit
::
walk_expr_opt
(
&
mut
visito
r
,
&
blk
.expr
);
walk_list!
(
&
mut
visitor
,
visit_exp
r
,
&
blk
.expr
);
if
visitor
.found
{
return
true
;
}
...
...
src/librustc_typeck/check/mod.rs
浏览文件 @
4744d568
...
...
@@ -376,6 +376,11 @@ fn visit_ty(&mut self, t: &'tcx hir::Ty) {
hir
::
TyFixedLengthVec
(
_
,
ref
expr
)
=>
{
check_const_in_type
(
self
.ccx
,
&**
expr
,
self
.ccx.tcx.types.usize
);
}
hir
::
TyBareFn
(
ref
function_declaration
)
=>
{
visit
::
walk_fn_decl_nopat
(
self
,
&
function_declaration
.decl
);
walk_list!
(
self
,
visit_lifetime_def
,
&
function_declaration
.lifetimes
);
return
}
_
=>
{}
}
...
...
@@ -560,6 +565,10 @@ fn visit_ty(&mut self, t: &'tcx hir::Ty) {
self
.visit_ty
(
&**
ty
);
check_expr_with_hint
(
self
.fcx
,
&**
count_expr
,
self
.fcx
.tcx
()
.types.usize
);
}
hir
::
TyBareFn
(
ref
function_declaration
)
=>
{
visit
::
walk_fn_decl_nopat
(
self
,
&
function_declaration
.decl
);
walk_list!
(
self
,
visit_lifetime_def
,
&
function_declaration
.lifetimes
);
}
_
=>
visit
::
walk_ty
(
self
,
t
)
}
}
...
...
src/librustc_typeck/check/writeback.rs
浏览文件 @
4744d568
...
...
@@ -225,6 +225,10 @@ fn visit_ty(&mut self, t: &hir::Ty) {
self
.visit_ty
(
&**
ty
);
write_ty_to_tcx
(
self
.tcx
(),
count_expr
.id
,
self
.tcx
()
.types.usize
);
}
hir
::
TyBareFn
(
ref
function_declaration
)
=>
{
visit
::
walk_fn_decl_nopat
(
self
,
&
function_declaration
.decl
);
walk_list!
(
self
,
visit_lifetime_def
,
&
function_declaration
.lifetimes
);
}
_
=>
visit
::
walk_ty
(
self
,
t
)
}
}
...
...
src/libsyntax/visit.rs
浏览文件 @
4744d568
...
...
@@ -131,7 +131,7 @@ fn visit_macro_def(&mut self, macro_def: &'v MacroDef) {
#[macro_export]
macro_rules!
walk_list
{
(
$visitor
:
ident
,
$method
:
ident
,
$list
:
expr
)
=>
{
(
$visitor
:
expr
,
$method
:
ident
,
$list
:
expr
)
=>
{
for
elem
in
$list
{
$visitor
.
$method
(
elem
)
}
...
...
@@ -530,23 +530,22 @@ pub fn walk_generics<'v, V: Visitor<'v>>(visitor: &mut V, generics: &'v Generics
}
}
pub
fn
walk_fn_ret_ty
<
'v
,
V
:
Visitor
<
'v
>>
(
visitor
:
&
mut
V
,
ret_ty
:
&
'v
FunctionRetTy
)
{
if
let
Return
(
ref
output_ty
)
=
*
ret_ty
{
visitor
.visit_ty
(
output_ty
)
}
}
pub
fn
walk_fn_decl
<
'v
,
V
:
Visitor
<
'v
>>
(
visitor
:
&
mut
V
,
function_declaration
:
&
'v
FnDecl
)
{
for
argument
in
&
function_declaration
.inputs
{
visitor
.visit_pat
(
&
argument
.pat
);
visitor
.visit_ty
(
&
argument
.ty
)
}
if
let
Return
(
ref
output_ty
)
=
function_declaration
.output
{
visitor
.visit_ty
(
output_ty
)
}
walk_fn_ret_ty
(
visitor
,
&
function_declaration
.output
)
}
pub
fn
walk_fn
<
'v
,
V
:
Visitor
<
'v
>>
(
visitor
:
&
mut
V
,
function_kind
:
FnKind
<
'v
>
,
function_declaration
:
&
'v
FnDecl
,
function_body
:
&
'v
Block
,
_
span
:
Span
)
{
walk_fn_decl
(
visitor
,
function_declaration
);
pub
fn
walk_fn_kind
<
'v
,
V
:
Visitor
<
'v
>>
(
visitor
:
&
mut
V
,
function_kind
:
FnKind
<
'v
>
)
{
match
function_kind
{
FnKind
::
ItemFn
(
_
,
generics
,
_
,
_
,
_
,
_
)
=>
{
visitor
.visit_generics
(
generics
);
...
...
@@ -557,7 +556,15 @@ pub fn walk_fn<'v, V: Visitor<'v>>(visitor: &mut V,
}
FnKind
::
Closure
=>
{}
}
}
pub
fn
walk_fn
<
'v
,
V
:
Visitor
<
'v
>>
(
visitor
:
&
mut
V
,
function_kind
:
FnKind
<
'v
>
,
function_declaration
:
&
'v
FnDecl
,
function_body
:
&
'v
Block
,
_
span
:
Span
)
{
walk_fn_decl
(
visitor
,
function_declaration
);
walk_fn_kind
(
visitor
,
function_kind
);
visitor
.visit_block
(
function_body
)
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录