Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
1a238589
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,发现更多精彩内容 >>
提交
1a238589
编写于
9月 12, 2021
作者:
V
Vadim Petrochenkov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
resolve: Rename some expansion def scope methods
上级
6e9adcbd
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
19 addition
and
23 deletion
+19
-23
compiler/rustc_resolve/src/build_reduced_graph.rs
compiler/rustc_resolve/src/build_reduced_graph.rs
+9
-12
compiler/rustc_resolve/src/imports.rs
compiler/rustc_resolve/src/imports.rs
+3
-3
compiler/rustc_resolve/src/lib.rs
compiler/rustc_resolve/src/lib.rs
+4
-4
compiler/rustc_resolve/src/macros.rs
compiler/rustc_resolve/src/macros.rs
+3
-4
未找到文件。
compiler/rustc_resolve/src/build_reduced_graph.rs
浏览文件 @
1a238589
...
...
@@ -152,20 +152,17 @@ pub fn get_module(&mut self, def_id: DefId) -> Module<'a> {
module
}
crate
fn
macro_def_scope
(
&
mut
self
,
expn_id
:
ExpnId
)
->
Module
<
'a
>
{
let
def_id
=
match
expn_id
.expn_data
()
.macro_def_id
{
Some
(
def_id
)
=>
def_id
,
None
=>
{
return
expn_id
.as_local
()
.and_then
(|
expn_id
|
self
.ast_transform_scopes
.get
(
&
expn_id
))
.unwrap_or
(
&
self
.graph_root
);
}
};
self
.macro_def_scope_from_def_id
(
def_id
)
crate
fn
expn_def_scope
(
&
mut
self
,
expn_id
:
ExpnId
)
->
Module
<
'a
>
{
match
expn_id
.expn_data
()
.macro_def_id
{
Some
(
def_id
)
=>
self
.macro_def_scope
(
def_id
),
None
=>
expn_id
.as_local
()
.and_then
(|
expn_id
|
self
.ast_transform_scopes
.get
(
&
expn_id
))
.unwrap_or
(
&
self
.graph_root
),
}
}
crate
fn
macro_def_scope
_from_def_id
(
&
mut
self
,
def_id
:
DefId
)
->
Module
<
'a
>
{
crate
fn
macro_def_scope
(
&
mut
self
,
def_id
:
DefId
)
->
Module
<
'a
>
{
if
let
Some
(
id
)
=
def_id
.as_local
()
{
self
.local_macro_def_scopes
[
&
id
]
}
else
{
...
...
compiler/rustc_resolve/src/imports.rs
浏览文件 @
1a238589
...
...
@@ -427,7 +427,7 @@ impl<'a> Resolver<'a> {
match
ident
.span
.glob_adjust
(
module
.expansion
,
glob_import
.span
)
{
Some
(
Some
(
def
))
=>
{
tmp_parent_scope
=
ParentScope
{
module
:
self
.
macro
_def_scope
(
def
),
..*
parent_scope
};
ParentScope
{
module
:
self
.
expn
_def_scope
(
def
),
..*
parent_scope
};
adjusted_parent_scope
=
&
tmp_parent_scope
;
}
Some
(
None
)
=>
{}
...
...
@@ -585,7 +585,7 @@ fn update_resolution<T, F>(&mut self, module: Module<'a>, key: BindingKey, f: F)
for
import
in
module
.glob_importers
.borrow_mut
()
.iter
()
{
let
mut
ident
=
key
.ident
;
let
scope
=
match
ident
.span
.reverse_glob_adjust
(
module
.expansion
,
import
.span
)
{
Some
(
Some
(
def
))
=>
self
.
macro
_def_scope
(
def
),
Some
(
Some
(
def
))
=>
self
.
expn
_def_scope
(
def
),
Some
(
None
)
=>
import
.parent_scope.module
,
None
=>
continue
,
};
...
...
@@ -1364,7 +1364,7 @@ fn resolve_glob_import(&mut self, import: &'b Import<'b>) {
.collect
::
<
Vec
<
_
>>
();
for
(
mut
key
,
binding
)
in
bindings
{
let
scope
=
match
key
.ident.span
.reverse_glob_adjust
(
module
.expansion
,
import
.span
)
{
Some
(
Some
(
def
))
=>
self
.r
.
macro
_def_scope
(
def
),
Some
(
Some
(
def
))
=>
self
.r
.
expn
_def_scope
(
def
),
Some
(
None
)
=>
import
.parent_scope.module
,
None
=>
continue
,
};
...
...
compiler/rustc_resolve/src/lib.rs
浏览文件 @
1a238589
...
...
@@ -2018,7 +2018,7 @@ fn hygienic_lexical_parent(
derive_fallback_lint_id
:
Option
<
NodeId
>
,
)
->
Option
<
(
Module
<
'a
>
,
Option
<
NodeId
>
)
>
{
if
!
module
.expansion
.outer_expn_is_descendant_of
(
*
ctxt
)
{
return
Some
((
self
.
macro
_def_scope
(
ctxt
.remove_mark
()),
None
));
return
Some
((
self
.
expn
_def_scope
(
ctxt
.remove_mark
()),
None
));
}
if
let
ModuleKind
::
Block
(
..
)
=
module
.kind
{
...
...
@@ -2087,7 +2087,7 @@ fn resolve_ident_in_module_ext(
ModuleOrUniformRoot
::
Module
(
m
)
=>
{
if
let
Some
(
def
)
=
ident
.span
.normalize_to_macros_2_0_and_adjust
(
m
.expansion
)
{
tmp_parent_scope
=
ParentScope
{
module
:
self
.
macro
_def_scope
(
def
),
..*
parent_scope
};
ParentScope
{
module
:
self
.
expn
_def_scope
(
def
),
..*
parent_scope
};
adjusted_parent_scope
=
&
tmp_parent_scope
;
}
}
...
...
@@ -2160,7 +2160,7 @@ fn resolve_crate_root(&mut self, ident: Ident) -> Module<'a> {
ctxt
.adjust
(
ExpnId
::
root
())
};
let
module
=
match
mark
{
Some
(
def
)
=>
self
.
macro
_def_scope
(
def
),
Some
(
def
)
=>
self
.
expn
_def_scope
(
def
),
None
=>
{
debug!
(
"resolve_crate_root({:?}): found no mark (ident.span = {:?})"
,
...
...
@@ -2185,7 +2185,7 @@ fn resolve_crate_root(&mut self, ident: Ident) -> Module<'a> {
fn
resolve_self
(
&
mut
self
,
ctxt
:
&
mut
SyntaxContext
,
module
:
Module
<
'a
>
)
->
Module
<
'a
>
{
let
mut
module
=
self
.get_module
(
module
.nearest_parent_mod
());
while
module
.span
.ctxt
()
.normalize_to_macros_2_0
()
!=
*
ctxt
{
let
parent
=
module
.parent
.unwrap_or_else
(||
self
.
macro
_def_scope
(
ctxt
.remove_mark
()));
let
parent
=
module
.parent
.unwrap_or_else
(||
self
.
expn
_def_scope
(
ctxt
.remove_mark
()));
module
=
self
.get_module
(
parent
.nearest_parent_mod
());
}
module
...
...
compiler/rustc_resolve/src/macros.rs
浏览文件 @
1a238589
...
...
@@ -298,15 +298,14 @@ fn resolve_macro_invocation(
)
?
;
let
span
=
invoc
.span
();
let
def_id
=
res
.opt_def_id
();
invoc_id
.set_expn_data
(
ext
.expn_data
(
parent_scope
.expansion
,
span
,
fast_print_path
(
path
),
res
.opt_def_id
(),
res
.opt_def_id
()
.map
(|
macro_def_id
|
{
self
.macro_def_scope_from_def_id
(
macro_def_id
)
.nearest_parent_mod
()
}),
def_id
,
def_id
.map
(|
def_id
|
self
.macro_def_scope
(
def_id
)
.nearest_parent_mod
()),
),
self
.create_stable_hashing_context
(),
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录