Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
b01e6300
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,发现更多精彩内容 >>
提交
b01e6300
编写于
4月 17, 2016
作者:
J
Jeffrey Seyfried
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refactor the per-module node map `module_children` into a per-resolver map.
上级
5b128320
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
22 addition
and
22 deletion
+22
-22
src/librustc_resolve/build_reduced_graph.rs
src/librustc_resolve/build_reduced_graph.rs
+2
-2
src/librustc_resolve/lib.rs
src/librustc_resolve/lib.rs
+20
-20
未找到文件。
src/librustc_resolve/build_reduced_graph.rs
浏览文件 @
b01e6300
...
...
@@ -260,7 +260,7 @@ fn build_reduced_graph_for_item(&mut self, item: &Item, parent_ref: &mut Module<
let
def
=
Def
::
Mod
(
self
.ast_map
.local_def_id
(
item
.id
));
let
module
=
self
.new_module
(
parent_link
,
Some
(
def
),
false
,
vis
);
self
.define
(
parent
,
name
,
TypeNS
,
(
module
,
sp
));
parent
.module_children
.borrow_mut
()
.insert
(
item
.id
,
module
);
self
.module_map
.insert
(
item
.id
,
module
);
*
parent_ref
=
module
;
}
...
...
@@ -398,7 +398,7 @@ fn build_reduced_graph_for_block(&mut self, block: &Block, parent: &mut Module<'
let
parent_link
=
BlockParentLink
(
parent
,
block_id
);
let
new_module
=
self
.new_module
(
parent_link
,
None
,
false
,
parent
.vis
);
parent
.module_children
.borrow_mut
()
.insert
(
block_id
,
new_module
);
self
.module_map
.insert
(
block_id
,
new_module
);
*
parent
=
new_module
;
}
}
...
...
src/librustc_resolve/lib.rs
浏览文件 @
b01e6300
...
...
@@ -827,22 +827,6 @@ pub struct ModuleS<'a> {
resolutions
:
RefCell
<
HashMap
<
(
Name
,
Namespace
),
&
'a
RefCell
<
NameResolution
<
'a
>>>>
,
unresolved_imports
:
RefCell
<
Vec
<&
'a
ImportDirective
<
'a
>>>
,
// The module children of this node, including normal modules and anonymous modules.
// Anonymous children are pseudo-modules that are implicitly created around items
// contained within blocks.
//
// For example, if we have this:
//
// fn f() {
// fn g() {
// ...
// }
// }
//
// There will be an anonymous module created around `g` with the ID of the
// entry block for `f`.
module_children
:
RefCell
<
NodeMap
<
Module
<
'a
>>>
,
prelude
:
RefCell
<
Option
<
Module
<
'a
>>>
,
glob_importers
:
RefCell
<
Vec
<
(
Module
<
'a
>
,
&
'a
ImportDirective
<
'a
>
)
>>
,
...
...
@@ -871,7 +855,6 @@ fn new(parent_link: ParentLink<'a>,
extern_crate_id
:
None
,
resolutions
:
RefCell
::
new
(
HashMap
::
new
()),
unresolved_imports
:
RefCell
::
new
(
Vec
::
new
()),
module_children
:
RefCell
::
new
(
NodeMap
()),
prelude
:
RefCell
::
new
(
None
),
glob_importers
:
RefCell
::
new
(
Vec
::
new
()),
globs
:
RefCell
::
new
((
Vec
::
new
())),
...
...
@@ -1078,6 +1061,22 @@ pub struct Resolver<'a, 'tcx: 'a> {
export_map
:
ExportMap
,
trait_map
:
TraitMap
,
// A map from nodes to modules, both normal (`mod`) modules and anonymous modules.
// Anonymous modules are pseudo-modules that are implicitly created around items
// contained within blocks.
//
// For example, if we have this:
//
// fn f() {
// fn g() {
// ...
// }
// }
//
// There will be an anonymous module created around `g` with the ID of the
// entry block for `f`.
module_map
:
NodeMap
<
Module
<
'a
>>
,
// Whether or not to print error messages. Can be set to true
// when getting additional info for error message suggestions,
// so as to avoid printing duplicate errors
...
...
@@ -1179,6 +1178,7 @@ fn new(session: &'a Session,
freevars_seen
:
NodeMap
(),
export_map
:
NodeMap
(),
trait_map
:
NodeMap
(),
module_map
:
NodeMap
(),
used_imports
:
HashSet
::
new
(),
used_crates
:
HashSet
::
new
(),
...
...
@@ -1578,7 +1578,8 @@ fn resolve_name_in_module(&mut self,
fn
with_scope
<
F
>
(
&
mut
self
,
id
:
NodeId
,
f
:
F
)
where
F
:
FnOnce
(
&
mut
Resolver
)
{
if
let
Some
(
module
)
=
self
.current_module.module_children
.borrow
()
.get
(
&
id
)
{
let
module
=
self
.module_map
.get
(
&
id
)
.cloned
();
// clones a reference
if
let
Some
(
module
)
=
module
{
// Move down in the graph.
let
orig_module
=
::
std
::
mem
::
replace
(
&
mut
self
.current_module
,
module
);
self
.value_ribs
.push
(
Rib
::
new
(
ModuleRibKind
(
module
)));
...
...
@@ -2129,8 +2130,7 @@ fn resolve_block(&mut self, block: &Block) {
debug!
(
"(resolving block) entering block"
);
// Move down in the graph, if there's an anonymous module rooted here.
let
orig_module
=
self
.current_module
;
let
anonymous_module
=
orig_module
.module_children
.borrow
()
.get
(
&
block
.id
)
.map
(|
module
|
*
module
);
let
anonymous_module
=
self
.module_map
.get
(
&
block
.id
)
.cloned
();
// clones a reference
if
let
Some
(
anonymous_module
)
=
anonymous_module
{
debug!
(
"(resolving block) found anonymous module, moving down"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录