Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
532b013b
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,发现更多精彩内容 >>
提交
532b013b
编写于
11月 26, 2016
作者:
J
Jeffrey Seyfried
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename `ModuleS` -> `ModuleData`.
上级
aa19274b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
18 addition
and
18 deletion
+18
-18
src/librustc_resolve/build_reduced_graph.rs
src/librustc_resolve/build_reduced_graph.rs
+5
-5
src/librustc_resolve/lib.rs
src/librustc_resolve/lib.rs
+13
-13
未找到文件。
src/librustc_resolve/build_reduced_graph.rs
浏览文件 @
532b013b
...
...
@@ -16,7 +16,7 @@
use
macros
::{
InvocationData
,
LegacyScope
};
use
resolve_imports
::
ImportDirective
;
use
resolve_imports
::
ImportDirectiveSubclass
::{
self
,
GlobImport
,
SingleImport
};
use
{
Module
,
Module
S
,
ModuleKind
,
NameBinding
,
NameBindingKind
,
ToNameBinding
};
use
{
Module
,
Module
Data
,
ModuleKind
,
NameBinding
,
NameBindingKind
,
ToNameBinding
};
use
{
Resolver
,
ResolverArenas
};
use
Namespace
::{
self
,
TypeNS
,
ValueNS
,
MacroNS
};
use
{
resolve_error
,
resolve_struct_error
,
ResolutionError
};
...
...
@@ -261,12 +261,12 @@ fn build_reduced_graph_for_item(&mut self, item: &Item, expansion: Mark) {
ItemKind
::
Mod
(
..
)
=>
{
let
def
=
Def
::
Mod
(
self
.definitions
.local_def_id
(
item
.id
));
let
module
=
self
.arenas
.alloc_module
(
Module
S
{
let
module
=
self
.arenas
.alloc_module
(
Module
Data
{
no_implicit_prelude
:
parent
.no_implicit_prelude
||
{
attr
::
contains_name
(
&
item
.attrs
,
"no_implicit_prelude"
)
},
normal_ancestor_id
:
Some
(
item
.id
),
..
Module
S
::
new
(
Some
(
parent
),
ModuleKind
::
Def
(
def
,
ident
.name
))
..
Module
Data
::
new
(
Some
(
parent
),
ModuleKind
::
Def
(
def
,
ident
.name
))
});
self
.define
(
parent
,
ident
,
TypeNS
,
(
module
,
vis
,
sp
,
expansion
));
self
.module_map
.insert
(
item
.id
,
module
);
...
...
@@ -493,9 +493,9 @@ fn get_extern_crate_root(&mut self, cnum: CrateNum) -> Module<'b> {
let
macros_only
=
self
.session.cstore
.dep_kind
(
cnum
)
.macros_only
();
let
arenas
=
self
.arenas
;
*
self
.extern_crate_roots
.entry
((
cnum
,
macros_only
))
.or_insert_with
(||
{
arenas
.alloc_module
(
Module
S
{
arenas
.alloc_module
(
Module
Data
{
populated
:
Cell
::
new
(
false
),
..
Module
S
::
new
(
None
,
ModuleKind
::
Def
(
Def
::
Mod
(
def_id
),
keywords
::
Invalid
.name
()))
..
Module
Data
::
new
(
None
,
ModuleKind
::
Def
(
Def
::
Mod
(
def_id
),
keywords
::
Invalid
.name
()))
})
})
}
...
...
src/librustc_resolve/lib.rs
浏览文件 @
532b013b
...
...
@@ -774,7 +774,7 @@ enum ModuleKind {
}
/// One node in the tree of modules.
pub
struct
Module
S
<
'a
>
{
pub
struct
Module
Data
<
'a
>
{
parent
:
Option
<
Module
<
'a
>>
,
kind
:
ModuleKind
,
...
...
@@ -802,11 +802,11 @@ pub struct ModuleS<'a> {
populated
:
Cell
<
bool
>
,
}
pub
type
Module
<
'a
>
=
&
'a
Module
S
<
'a
>
;
pub
type
Module
<
'a
>
=
&
'a
Module
Data
<
'a
>
;
impl
<
'a
>
Module
S
<
'a
>
{
impl
<
'a
>
Module
Data
<
'a
>
{
fn
new
(
parent
:
Option
<
Module
<
'a
>>
,
kind
:
ModuleKind
)
->
Self
{
Module
S
{
Module
Data
{
parent
:
parent
,
kind
:
kind
,
normal_ancestor_id
:
None
,
...
...
@@ -859,7 +859,7 @@ fn is_local(&self) -> bool {
}
}
impl
<
'a
>
fmt
::
Debug
for
Module
S
<
'a
>
{
impl
<
'a
>
fmt
::
Debug
for
Module
Data
<
'a
>
{
fn
fmt
(
&
self
,
f
:
&
mut
fmt
::
Formatter
)
->
fmt
::
Result
{
write!
(
f
,
"{:?}"
,
self
.def
())
}
...
...
@@ -1116,7 +1116,7 @@ pub struct Resolver<'a> {
}
pub
struct
ResolverArenas
<
'a
>
{
modules
:
arena
::
TypedArena
<
Module
S
<
'a
>>
,
modules
:
arena
::
TypedArena
<
Module
Data
<
'a
>>
,
local_modules
:
RefCell
<
Vec
<
Module
<
'a
>>>
,
name_bindings
:
arena
::
TypedArena
<
NameBinding
<
'a
>>
,
import_directives
:
arena
::
TypedArena
<
ImportDirective
<
'a
>>
,
...
...
@@ -1126,7 +1126,7 @@ pub struct ResolverArenas<'a> {
}
impl
<
'a
>
ResolverArenas
<
'a
>
{
fn
alloc_module
(
&
'a
self
,
module
:
Module
S
<
'a
>
)
->
Module
<
'a
>
{
fn
alloc_module
(
&
'a
self
,
module
:
Module
Data
<
'a
>
)
->
Module
<
'a
>
{
let
module
=
self
.modules
.alloc
(
module
);
if
module
.def_id
()
.map
(|
def_id
|
def_id
.is_local
())
.unwrap_or
(
true
)
{
self
.local_modules
.borrow_mut
()
.push
(
module
);
...
...
@@ -1206,10 +1206,10 @@ pub fn new(session: &'a Session,
arenas
:
&
'a
ResolverArenas
<
'a
>
)
->
Resolver
<
'a
>
{
let
root_def
=
Def
::
Mod
(
DefId
::
local
(
CRATE_DEF_INDEX
));
let
graph_root
=
arenas
.alloc_module
(
Module
S
{
let
graph_root
=
arenas
.alloc_module
(
Module
Data
{
normal_ancestor_id
:
Some
(
CRATE_NODE_ID
),
no_implicit_prelude
:
attr
::
contains_name
(
&
krate
.attrs
,
"no_implicit_prelude"
),
..
Module
S
::
new
(
None
,
ModuleKind
::
Def
(
root_def
,
keywords
::
Invalid
.name
()))
..
Module
Data
::
new
(
None
,
ModuleKind
::
Def
(
root_def
,
keywords
::
Invalid
.name
()))
});
let
mut
module_map
=
NodeMap
();
module_map
.insert
(
CRATE_NODE_ID
,
graph_root
);
...
...
@@ -1327,17 +1327,17 @@ pub fn resolve_crate(&mut self, krate: &Crate) {
}
fn
new_module
(
&
self
,
parent
:
Module
<
'a
>
,
kind
:
ModuleKind
,
local
:
bool
)
->
Module
<
'a
>
{
self
.arenas
.alloc_module
(
Module
S
{
self
.arenas
.alloc_module
(
Module
Data
{
normal_ancestor_id
:
if
local
{
self
.current_module.normal_ancestor_id
}
else
{
None
},
populated
:
Cell
::
new
(
local
),
..
Module
S
::
new
(
Some
(
parent
),
kind
)
..
Module
Data
::
new
(
Some
(
parent
),
kind
)
})
}
fn
record_use
(
&
mut
self
,
ident
:
Ident
,
ns
:
Namespace
,
binding
:
&
'a
NameBinding
<
'a
>
,
span
:
Span
)
->
bool
/* true if an error was reported */
{
// track extern crates for unused_extern_crate lint
if
let
Some
(
DefId
{
krate
,
..
})
=
binding
.module
()
.and_then
(
Module
S
::
def_id
)
{
if
let
Some
(
DefId
{
krate
,
..
})
=
binding
.module
()
.and_then
(
Module
Data
::
def_id
)
{
self
.used_crates
.insert
(
krate
);
}
...
...
@@ -2403,7 +2403,7 @@ fn resolve_path(&mut self,
});
}
}
let
msg
=
if
module
.and_then
(
Module
S
::
def
)
==
self
.graph_root
.def
()
{
let
msg
=
if
module
.and_then
(
Module
Data
::
def
)
==
self
.graph_root
.def
()
{
let
is_mod
=
|
def
|
match
def
{
Def
::
Mod
(
..
)
=>
true
,
_
=>
false
};
let
mut
candidates
=
self
.lookup_candidates
(
ident
.name
,
TypeNS
,
is_mod
)
.candidates
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录