Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
fffe9fbb
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,发现更多精彩内容 >>
提交
fffe9fbb
编写于
6月 23, 2018
作者:
V
Vadim Petrochenkov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
hygiene: More descriptive names for things involved in late hygienic name resolution
上级
296955a6
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
26 addition
and
19 deletion
+26
-19
src/librustc/hir/map/definitions.rs
src/librustc/hir/map/definitions.rs
+18
-13
src/librustc/ty/mod.rs
src/librustc/ty/mod.rs
+6
-5
src/librustc_resolve/macros.rs
src/librustc_resolve/macros.rs
+2
-1
未找到文件。
src/librustc/hir/map/definitions.rs
浏览文件 @
fffe9fbb
...
...
@@ -157,8 +157,13 @@ pub struct Definitions {
node_to_def_index
:
NodeMap
<
DefIndex
>
,
def_index_to_node
:
[
Vec
<
ast
::
NodeId
>
;
2
],
pub
(
super
)
node_to_hir_id
:
IndexVec
<
ast
::
NodeId
,
hir
::
HirId
>
,
macro_def_scopes
:
FxHashMap
<
Mark
,
DefId
>
,
expansions
:
FxHashMap
<
DefIndex
,
Mark
>
,
/// If `Mark` is an ID of some macro expansion,
/// then `DefId` is the normal module (`mod`) in which the expanded macro was defined.
parent_modules_of_macro_defs
:
FxHashMap
<
Mark
,
DefId
>
,
/// Item with a given `DefIndex` was defined during opaque macro expansion with ID `Mark`.
/// It can actually be defined during transparent macro expansions inside that opaque expansion,
/// but transparent expansions are ignored here.
opaque_expansions_that_defined
:
FxHashMap
<
DefIndex
,
Mark
>
,
next_disambiguator
:
FxHashMap
<
(
DefIndex
,
DefPathData
),
u32
>
,
def_index_to_span
:
FxHashMap
<
DefIndex
,
Span
>
,
}
...
...
@@ -175,8 +180,8 @@ fn clone(&self) -> Self {
self
.def_index_to_node
[
1
]
.clone
(),
],
node_to_hir_id
:
self
.node_to_hir_id
.clone
(),
macro_def_scopes
:
self
.macro_def_scope
s
.clone
(),
expansions
:
self
.expansions
.clone
(),
parent_modules_of_macro_defs
:
self
.parent_modules_of_macro_def
s
.clone
(),
opaque_expansions_that_defined
:
self
.opaque_expansions_that_defined
.clone
(),
next_disambiguator
:
self
.next_disambiguator
.clone
(),
def_index_to_span
:
self
.def_index_to_span
.clone
(),
}
...
...
@@ -397,8 +402,8 @@ pub fn new() -> Definitions {
node_to_def_index
:
NodeMap
(),
def_index_to_node
:
[
vec!
[],
vec!
[]],
node_to_hir_id
:
IndexVec
::
new
(),
macro_def_scope
s
:
FxHashMap
(),
expansions
:
FxHashMap
(),
parent_modules_of_macro_def
s
:
FxHashMap
(),
opaque_expansions_that_defined
:
FxHashMap
(),
next_disambiguator
:
FxHashMap
(),
def_index_to_span
:
FxHashMap
(),
}
...
...
@@ -580,7 +585,7 @@ pub fn create_def_with_parent(&mut self,
let
expansion
=
expansion
.modern
();
if
expansion
!=
Mark
::
root
()
{
self
.
expansions
.insert
(
index
,
expansion
);
self
.
opaque_expansions_that_defined
.insert
(
index
,
expansion
);
}
// The span is added if it isn't DUMMY_SP
...
...
@@ -600,16 +605,16 @@ pub fn init_node_id_to_hir_id_mapping(&mut self,
self
.node_to_hir_id
=
mapping
;
}
pub
fn
expansion
(
&
self
,
index
:
DefIndex
)
->
Mark
{
self
.
expansions
.get
(
&
index
)
.cloned
()
.unwrap_or
(
Mark
::
root
())
pub
fn
opaque_expansion_that_defined
(
&
self
,
index
:
DefIndex
)
->
Mark
{
self
.
opaque_expansions_that_defined
.get
(
&
index
)
.cloned
()
.unwrap_or
(
Mark
::
root
())
}
pub
fn
macro_def_scope
(
&
self
,
mark
:
Mark
)
->
DefId
{
self
.
macro_def_scope
s
[
&
mark
]
pub
fn
parent_module_of_macro_def
(
&
self
,
mark
:
Mark
)
->
DefId
{
self
.
parent_modules_of_macro_def
s
[
&
mark
]
}
pub
fn
add_
macro_def_scope
(
&
mut
self
,
mark
:
Mark
,
scop
e
:
DefId
)
{
self
.
macro_def_scopes
.insert
(
mark
,
scop
e
);
pub
fn
add_
parent_module_of_macro_def
(
&
mut
self
,
mark
:
Mark
,
modul
e
:
DefId
)
{
self
.
parent_modules_of_macro_defs
.insert
(
mark
,
modul
e
);
}
}
...
...
src/librustc/ty/mod.rs
浏览文件 @
fffe9fbb
...
...
@@ -2732,13 +2732,14 @@ pub fn hygienic_eq(self, use_name: Name, def_name: Name, def_parent_def_id: DefI
}
pub
fn
adjust_ident
(
self
,
mut
ident
:
Ident
,
scope
:
DefId
,
block
:
NodeId
)
->
(
Ident
,
DefId
)
{
let
expansion
=
match
scope
.krate
{
LOCAL_CRATE
=>
self
.hir
.definitions
()
.expansion
(
scope
.index
),
ident
=
ident
.modern
();
let
target_expansion
=
match
scope
.krate
{
LOCAL_CRATE
=>
self
.hir
.definitions
()
.opaque_expansion_that_defined
(
scope
.index
),
_
=>
Mark
::
root
(),
};
ident
=
ident
.modern
();
let
scope
=
match
ident
.span
.adjust
(
expansion
)
{
Some
(
macro_def
)
=>
self
.hir
.definitions
()
.macro_def_scope
(
macro_def
),
let
scope
=
match
ident
.span
.adjust
(
target_expansion
)
{
Some
(
actual_expansion
)
=>
self
.hir
.definitions
()
.parent_module_of_macro_def
(
actual_expansion
),
None
if
block
==
DUMMY_NODE_ID
=>
DefId
::
local
(
CRATE_DEF_INDEX
),
// Dummy DefId
None
=>
self
.hir
.get_module_parent
(
block
),
};
...
...
src/librustc_resolve/macros.rs
浏览文件 @
fffe9fbb
...
...
@@ -327,7 +327,8 @@ fn resolve_invoc(&mut self, invoc: &mut Invocation, scope: Mark, force: bool)
self
.macro_defs
.insert
(
invoc
.expansion_data.mark
,
def_id
);
let
normal_module_def_id
=
self
.macro_def_scope
(
invoc
.expansion_data.mark
)
.normal_ancestor_id
;
self
.definitions
.add_macro_def_scope
(
invoc
.expansion_data.mark
,
normal_module_def_id
);
self
.definitions
.add_parent_module_of_macro_def
(
invoc
.expansion_data.mark
,
normal_module_def_id
);
self
.unused_macros
.remove
(
&
def_id
);
let
ext
=
self
.get_macro
(
def
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录