Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
77f0f4a6
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,发现更多精彩内容 >>
提交
77f0f4a6
编写于
3月 02, 2016
作者:
J
Jeffrey Seyfried
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Avoid repeating parent
上级
ff014a3a
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
11 addition
and
25 deletion
+11
-25
src/librustc_resolve/build_reduced_graph.rs
src/librustc_resolve/build_reduced_graph.rs
+11
-25
未找到文件。
src/librustc_resolve/build_reduced_graph.rs
浏览文件 @
77f0f4a6
...
...
@@ -43,7 +43,6 @@
use
rustc_front
::
hir
::{
Variant
,
ViewPathGlob
,
ViewPathList
,
ViewPathSimple
};
use
rustc_front
::
intravisit
::{
self
,
Visitor
};
use
std
::
mem
::
replace
;
use
std
::
ops
::{
Deref
,
DerefMut
};
struct
GraphBuilder
<
'a
,
'b
:
'a
,
'tcx
:
'b
>
{
...
...
@@ -122,7 +121,8 @@ fn is_item(statement: &hir::Stmt) -> bool {
}
/// Constructs the reduced graph for one item.
fn
build_reduced_graph_for_item
(
&
mut
self
,
item
:
&
Item
,
parent
:
Module
<
'b
>
)
->
Module
<
'b
>
{
fn
build_reduced_graph_for_item
(
&
mut
self
,
item
:
&
Item
,
parent_ref
:
&
mut
Module
<
'b
>
)
{
let
parent
=
*
parent_ref
;
let
name
=
item
.name
;
let
sp
=
item
.span
;
let
is_public
=
item
.vis
==
hir
::
Public
;
...
...
@@ -242,7 +242,6 @@ fn build_reduced_graph_for_item(&mut self, item: &Item, parent: Module<'b>) -> M
is_prelude
);
}
}
parent
}
ItemExternCrate
(
_
)
=>
{
...
...
@@ -260,7 +259,6 @@ fn build_reduced_graph_for_item(&mut self, item: &Item, parent: Module<'b>) -> M
self
.build_reduced_graph_for_external_crate
(
module
);
}
parent
}
ItemMod
(
..
)
=>
{
...
...
@@ -269,34 +267,30 @@ fn build_reduced_graph_for_item(&mut self, item: &Item, parent: Module<'b>) -> M
let
module
=
self
.new_module
(
parent_link
,
Some
(
def
),
false
,
is_public
);
self
.define
(
parent
,
name
,
TypeNS
,
(
module
,
sp
));
parent
.module_children
.borrow_mut
()
.insert
(
item
.id
,
module
);
module
*
parent_ref
=
module
;
}
ItemForeignMod
(
..
)
=>
parent
,
ItemForeignMod
(
..
)
=>
{}
// These items live in the value namespace.
ItemStatic
(
_
,
m
,
_
)
=>
{
let
mutbl
=
m
==
hir
::
MutMutable
;
let
def
=
Def
::
Static
(
self
.ast_map
.local_def_id
(
item
.id
),
mutbl
);
self
.define
(
parent
,
name
,
ValueNS
,
(
def
,
sp
,
modifiers
));
parent
}
ItemConst
(
_
,
_
)
=>
{
let
def
=
Def
::
Const
(
self
.ast_map
.local_def_id
(
item
.id
));
self
.define
(
parent
,
name
,
ValueNS
,
(
def
,
sp
,
modifiers
));
parent
}
ItemFn
(
_
,
_
,
_
,
_
,
_
,
_
)
=>
{
let
def
=
Def
::
Fn
(
self
.ast_map
.local_def_id
(
item
.id
));
self
.define
(
parent
,
name
,
ValueNS
,
(
def
,
sp
,
modifiers
));
parent
}
// These items live in the type namespace.
ItemTy
(
..
)
=>
{
let
def
=
Def
::
TyAlias
(
self
.ast_map
.local_def_id
(
item
.id
));
self
.define
(
parent
,
name
,
TypeNS
,
(
def
,
sp
,
modifiers
));
parent
}
ItemEnum
(
ref
enum_definition
,
_
)
=>
{
...
...
@@ -315,7 +309,6 @@ fn build_reduced_graph_for_item(&mut self, item: &Item, parent: Module<'b>) -> M
self
.build_reduced_graph_for_variant
(
variant
,
item_def_id
,
module
,
variant_modifiers
);
}
parent
}
// These items live in both the type and value namespaces.
...
...
@@ -338,12 +331,9 @@ fn build_reduced_graph_for_item(&mut self, item: &Item, parent: Module<'b>) -> M
.collect
();
let
item_def_id
=
self
.ast_map
.local_def_id
(
item
.id
);
self
.structs
.insert
(
item_def_id
,
field_names
);
parent
}
ItemDefaultImpl
(
_
,
_
)
|
ItemImpl
(
..
)
=>
parent
,
ItemDefaultImpl
(
_
,
_
)
|
ItemImpl
(
..
)
=>
{}
ItemTrait
(
_
,
_
,
_
,
ref
items
)
=>
{
let
def_id
=
self
.ast_map
.local_def_id
(
item
.id
);
...
...
@@ -368,8 +358,6 @@ fn build_reduced_graph_for_item(&mut self, item: &Item, parent: Module<'b>) -> M
self
.trait_item_map
.insert
((
item
.name
,
def_id
),
item_def_id
);
}
parent
}
}
}
...
...
@@ -420,7 +408,7 @@ fn build_reduced_graph_for_foreign_item(&mut self,
self
.define
(
parent
,
name
,
ValueNS
,
(
def
,
foreign_item
.span
,
modifiers
));
}
fn
build_reduced_graph_for_block
(
&
mut
self
,
block
:
&
Block
,
parent
:
Module
<
'b
>
)
->
Module
<
'b
>
{
fn
build_reduced_graph_for_block
(
&
mut
self
,
block
:
&
Block
,
parent
:
&
mut
Module
<
'b
>
)
{
if
self
.block_needs_anonymous_module
(
block
)
{
let
block_id
=
block
.id
;
...
...
@@ -431,9 +419,7 @@ fn build_reduced_graph_for_block(&mut self, block: &Block, parent: Module<'b>) -
let
parent_link
=
BlockParentLink
(
parent
,
block_id
);
let
new_module
=
self
.new_module
(
parent_link
,
None
,
false
,
false
);
parent
.module_children
.borrow_mut
()
.insert
(
block_id
,
new_module
);
new_module
}
else
{
parent
*
parent
=
new_module
;
}
}
...
...
@@ -610,8 +596,8 @@ fn visit_nested_item(&mut self, item: hir::ItemId) {
}
fn
visit_item
(
&
mut
self
,
item
:
&
Item
)
{
let
p
=
self
.builder
.build_reduced_graph_for_item
(
item
,
&
self
.parent
)
;
let
old_parent
=
replace
(
&
mut
self
.parent
,
p
);
let
old_parent
=
self
.parent
;
self
.builder
.build_reduced_graph_for_item
(
item
,
&
mut
self
.parent
);
intravisit
::
walk_item
(
self
,
item
);
self
.parent
=
old_parent
;
}
...
...
@@ -621,8 +607,8 @@ fn visit_foreign_item(&mut self, foreign_item: &ForeignItem) {
}
fn
visit_block
(
&
mut
self
,
block
:
&
Block
)
{
let
np
=
self
.builder
.build_reduced_graph_for_block
(
block
,
&
self
.parent
)
;
let
old_parent
=
replace
(
&
mut
self
.parent
,
np
);
let
old_parent
=
self
.parent
;
self
.builder
.build_reduced_graph_for_block
(
block
,
&
mut
self
.parent
);
intravisit
::
walk_block
(
self
,
block
);
self
.parent
=
old_parent
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录