Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
60c8f7db
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,发现更多精彩内容 >>
提交
60c8f7db
编写于
4月 23, 2016
作者:
J
Jeffrey Seyfried
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Revert #27493
上级
8b1dcf40
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
16 addition
and
67 deletion
+16
-67
src/librustc_resolve/lib.rs
src/librustc_resolve/lib.rs
+16
-67
未找到文件。
src/librustc_resolve/lib.rs
浏览文件 @
60c8f7db
...
...
@@ -97,17 +97,6 @@
mod
build_reduced_graph
;
mod
resolve_imports
;
// Perform the callback, not walking deeper if the return is true
macro_rules!
execute_callback
{
(
$node
:
expr
,
$walker
:
expr
)
=>
(
if
let
Some
(
ref
callback
)
=
$walker
.callback
{
if
callback
(
$node
,
&
mut
$walker
.resolved
)
{
return
;
}
}
)
}
enum
SuggestionType
{
Macro
(
String
),
Function
(
token
::
InternedString
),
...
...
@@ -559,22 +548,18 @@ fn visit_nested_item(&mut self, item: hir::ItemId) {
self
.visit_item
(
self
.ast_map
.expect_item
(
item
.id
))
}
fn
visit_item
(
&
mut
self
,
item
:
&
Item
)
{
execute_callback!
(
hir_map
::
Node
::
NodeItem
(
item
),
self
);
self
.resolve_item
(
item
);
}
fn
visit_arm
(
&
mut
self
,
arm
:
&
Arm
)
{
self
.resolve_arm
(
arm
);
}
fn
visit_block
(
&
mut
self
,
block
:
&
Block
)
{
execute_callback!
(
hir_map
::
Node
::
NodeBlock
(
block
),
self
);
self
.resolve_block
(
block
);
}
fn
visit_expr
(
&
mut
self
,
expr
:
&
Expr
)
{
execute_callback!
(
hir_map
::
Node
::
NodeExpr
(
expr
),
self
);
self
.resolve_expr
(
expr
);
}
fn
visit_local
(
&
mut
self
,
local
:
&
Local
)
{
execute_callback!
(
hir_map
::
Node
::
NodeLocal
(
&
local
.pat
),
self
);
self
.resolve_local
(
local
);
}
fn
visit_ty
(
&
mut
self
,
ty
:
&
Ty
)
{
...
...
@@ -597,7 +582,6 @@ fn visit_variant(&mut self,
variant
:
&
hir
::
Variant
,
generics
:
&
Generics
,
item_id
:
ast
::
NodeId
)
{
execute_callback!
(
hir_map
::
Node
::
NodeVariant
(
variant
),
self
);
if
let
Some
(
ref
dis_expr
)
=
variant
.node.disr_expr
{
// resolve the discriminator expr as a constant
self
.with_constant_rib
(|
this
|
{
...
...
@@ -613,7 +597,6 @@ fn visit_variant(&mut self,
variant
.span
);
}
fn
visit_foreign_item
(
&
mut
self
,
foreign_item
:
&
hir
::
ForeignItem
)
{
execute_callback!
(
hir_map
::
Node
::
NodeForeignItem
(
foreign_item
),
self
);
let
type_parameters
=
match
foreign_item
.node
{
ForeignItemFn
(
_
,
ref
generics
)
=>
{
HasTypeParameters
(
generics
,
FnSpace
,
ItemRibKind
)
...
...
@@ -1080,11 +1063,6 @@ pub struct Resolver<'a, 'tcx: 'a> {
used_imports
:
HashSet
<
(
NodeId
,
Namespace
)
>
,
used_crates
:
HashSet
<
CrateNum
>
,
// Callback function for intercepting walks
callback
:
Option
<
Box
<
Fn
(
hir_map
::
Node
,
&
mut
bool
)
->
bool
>>
,
// The intention is that the callback modifies this flag.
// Once set, the resolver falls out of the walk, preserving the ribs.
resolved
:
bool
,
privacy_errors
:
Vec
<
PrivacyError
<
'a
>>
,
arenas
:
&
'a
ResolverArenas
<
'a
>
,
...
...
@@ -1186,8 +1164,6 @@ fn new(session: &'a Session,
make_glob_map
:
make_glob_map
==
MakeGlobMap
::
Yes
,
glob_map
:
NodeMap
(),
callback
:
None
,
resolved
:
false
,
privacy_errors
:
Vec
::
new
(),
arenas
:
arenas
,
...
...
@@ -1758,13 +1734,8 @@ fn with_type_parameter_rib<'b, F>(&'b mut self, type_parameters: TypeParameters<
f
(
self
);
match
type_parameters
{
HasTypeParameters
(
..
)
=>
{
if
!
self
.resolved
{
self
.type_ribs
.pop
();
}
}
NoTypeParameters
=>
{}
if
let
HasTypeParameters
(
..
)
=
type_parameters
{
self
.type_ribs
.pop
();
}
}
...
...
@@ -1773,9 +1744,7 @@ fn with_label_rib<F>(&mut self, f: F)
{
self
.label_ribs
.push
(
Rib
::
new
(
NormalRibKind
));
f
(
self
);
if
!
self
.resolved
{
self
.label_ribs
.pop
();
}
self
.label_ribs
.pop
();
}
fn
with_constant_rib
<
F
>
(
&
mut
self
,
f
:
F
)
...
...
@@ -1784,10 +1753,8 @@ fn with_constant_rib<F>(&mut self, f: F)
self
.value_ribs
.push
(
Rib
::
new
(
ConstantItemRibKind
));
self
.type_ribs
.push
(
Rib
::
new
(
ConstantItemRibKind
));
f
(
self
);
if
!
self
.resolved
{
self
.type_ribs
.pop
();
self
.value_ribs
.pop
();
}
self
.type_ribs
.pop
();
self
.value_ribs
.pop
();
}
fn
resolve_function
(
&
mut
self
,
rib_kind
:
RibKind
<
'a
>
,
declaration
:
&
FnDecl
,
block
:
&
Block
)
{
...
...
@@ -1813,10 +1780,8 @@ fn resolve_function(&mut self, rib_kind: RibKind<'a>, declaration: &FnDecl, bloc
debug!
(
"(resolving function) leaving function"
);
if
!
self
.resolved
{
self
.label_ribs
.pop
();
self
.value_ribs
.pop
();
}
self
.label_ribs
.pop
();
self
.value_ribs
.pop
();
}
fn
resolve_trait_reference
(
&
mut
self
,
...
...
@@ -1950,9 +1915,7 @@ fn with_self_rib<F>(&mut self, self_def: Def, f: F)
self_type_rib
.bindings
.insert
(
keywords
::
SelfType
.name
(),
self_def
);
self
.type_ribs
.push
(
self_type_rib
);
f
(
self
);
if
!
self
.resolved
{
self
.type_ribs
.pop
();
}
self
.type_ribs
.pop
();
}
fn
resolve_implementation
(
&
mut
self
,
...
...
@@ -2117,9 +2080,7 @@ fn resolve_arm(&mut self, arm: &Arm) {
walk_list!
(
self
,
visit_expr
,
&
arm
.guard
);
self
.visit_expr
(
&
arm
.body
);
if
!
self
.resolved
{
self
.value_ribs
.pop
();
}
self
.value_ribs
.pop
();
}
fn
resolve_block
(
&
mut
self
,
block
:
&
Block
)
{
...
...
@@ -2141,12 +2102,10 @@ fn resolve_block(&mut self, block: &Block) {
intravisit
::
walk_block
(
self
,
block
);
// Move back up.
if
!
self
.resolved
{
self
.current_module
=
orig_module
;
self
.value_ribs
.pop
();
if
let
Some
(
_
)
=
anonymous_module
{
self
.type_ribs
.pop
();
}
self
.current_module
=
orig_module
;
self
.value_ribs
.pop
();
if
let
Some
(
_
)
=
anonymous_module
{
self
.type_ribs
.pop
();
}
debug!
(
"(resolving block) leaving block"
);
}
...
...
@@ -3588,7 +3547,7 @@ pub fn resolve_crate<'a, 'tcx>(session: &'a Session,
let
krate
=
ast_map
.krate
();
let
arenas
=
Resolver
::
arenas
();
let
mut
resolver
=
create_resolver
(
session
,
ast_map
,
krate
,
make_glob_map
,
&
arenas
,
None
);
let
mut
resolver
=
create_resolver
(
session
,
ast_map
,
krate
,
make_glob_map
,
&
arenas
);
resolver
.resolve_crate
(
krate
);
...
...
@@ -3608,25 +3567,15 @@ pub fn resolve_crate<'a, 'tcx>(session: &'a Session,
}
}
/// Builds a name resolution walker to be used within this module,
/// or used externally, with an optional callback function.
///
/// The callback takes a &mut bool which allows callbacks to end a
/// walk when set to true, passing through the rest of the walk, while
/// preserving the ribs + current module. This allows resolve_path
/// calls to be made with the correct scope info. The node in the
/// callback corresponds to the current node in the walk.
/// Builds a name resolution walker.
fn
create_resolver
<
'a
,
'tcx
>
(
session
:
&
'a
Session
,
ast_map
:
&
'a
hir_map
::
Map
<
'tcx
>
,
krate
:
&
'a
Crate
,
make_glob_map
:
MakeGlobMap
,
arenas
:
&
'a
ResolverArenas
<
'a
>
,
callback
:
Option
<
Box
<
Fn
(
hir_map
::
Node
,
&
mut
bool
)
->
bool
>>
)
arenas
:
&
'a
ResolverArenas
<
'a
>
)
->
Resolver
<
'a
,
'tcx
>
{
let
mut
resolver
=
Resolver
::
new
(
session
,
ast_map
,
make_glob_map
,
arenas
);
resolver
.callback
=
callback
;
resolver
.build_reduced_graph
(
krate
);
resolve_imports
::
resolve_imports
(
&
mut
resolver
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录