Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
ffedcec4
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,发现更多精彩内容 >>
提交
ffedcec4
编写于
4月 30, 2022
作者:
V
Vadim Petrochenkov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
resolve: Pass full `Finalize` in nearly all cases
上级
900607f4
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
18 addition
and
20 deletion
+18
-20
compiler/rustc_resolve/src/ident.rs
compiler/rustc_resolve/src/ident.rs
+14
-16
compiler/rustc_resolve/src/imports.rs
compiler/rustc_resolve/src/imports.rs
+2
-2
compiler/rustc_resolve/src/macros.rs
compiler/rustc_resolve/src/macros.rs
+2
-2
未找到文件。
compiler/rustc_resolve/src/ident.rs
浏览文件 @
ffedcec4
...
...
@@ -279,7 +279,7 @@ fn hygienic_lexical_parent(
mut
ident
:
Ident
,
ns
:
Namespace
,
parent_scope
:
&
ParentScope
<
'a
>
,
finalize
_full
:
Option
<
Finalize
>
,
finalize
:
Option
<
Finalize
>
,
ribs
:
&
[
Rib
<
'a
>
],
unusable_binding
:
Option
<&
'a
NameBinding
<
'a
>>
,
)
->
Option
<
LexicalScopeBinding
<
'a
>>
{
...
...
@@ -302,7 +302,6 @@ fn hygienic_lexical_parent(
let
normalized_ident
=
Ident
{
span
:
normalized_span
,
..
ident
};
// Walk backwards up the ribs in scope.
let
finalize
=
finalize_full
.map
(|
finalize
|
finalize
.path_span
);
let
mut
module
=
self
.graph_root
;
for
i
in
(
0
..
ribs
.len
())
.rev
()
{
debug!
(
"walk rib
\n
{:?}"
,
ribs
[
i
]
.bindings
);
...
...
@@ -316,7 +315,7 @@ fn hygienic_lexical_parent(
i
,
rib_ident
,
*
res
,
finalize
,
finalize
.map
(|
finalize
|
finalize
.path_span
)
,
*
original_rib_ident_def
,
ribs
,
)));
...
...
@@ -354,7 +353,7 @@ fn hygienic_lexical_parent(
}
self
.early_resolve_ident_in_lexical_scope
(
orig_ident
,
ScopeSet
::
Late
(
ns
,
module
,
finalize
_full
.map
(|
finalize
|
finalize
.node_id
)),
ScopeSet
::
Late
(
ns
,
module
,
finalize
.map
(|
finalize
|
finalize
.node_id
)),
parent_scope
,
finalize
,
finalize
.is_some
(),
...
...
@@ -376,7 +375,7 @@ fn hygienic_lexical_parent(
orig_ident
:
Ident
,
scope_set
:
ScopeSet
<
'a
>
,
parent_scope
:
&
ParentScope
<
'a
>
,
finalize
:
Option
<
Span
>
,
finalize
:
Option
<
Finalize
>
,
force
:
bool
,
last_import_segment
:
bool
,
unusable_binding
:
Option
<&
'a
NameBinding
<
'a
>>
,
...
...
@@ -742,7 +741,7 @@ struct Flags: u8 {
ident
:
Ident
,
ns
:
Namespace
,
parent_scope
:
&
ParentScope
<
'a
>
,
finalize
:
Option
<
Span
>
,
finalize
:
Option
<
Finalize
>
,
// We are resolving a last import segment during import validation.
last_import_segment
:
bool
,
// This binding should be ignored during in-module resolution, so that we don't get
...
...
@@ -768,7 +767,7 @@ fn resolve_ident_in_module_ext(
mut
ident
:
Ident
,
ns
:
Namespace
,
parent_scope
:
&
ParentScope
<
'a
>
,
finalize
:
Option
<
Span
>
,
finalize
:
Option
<
Finalize
>
,
last_import_segment
:
bool
,
unusable_binding
:
Option
<&
'a
NameBinding
<
'a
>>
,
)
->
Result
<&
'a
NameBinding
<
'a
>
,
(
Determinacy
,
Weak
)
>
{
...
...
@@ -808,7 +807,7 @@ fn resolve_ident_in_module_unadjusted(
ident
:
Ident
,
ns
:
Namespace
,
parent_scope
:
&
ParentScope
<
'a
>
,
finalize
:
Option
<
Span
>
,
finalize
:
Option
<
Finalize
>
,
last_import_segment
:
bool
,
unusable_binding
:
Option
<&
'a
NameBinding
<
'a
>>
,
)
->
Result
<&
'a
NameBinding
<
'a
>
,
Determinacy
>
{
...
...
@@ -835,7 +834,7 @@ fn resolve_ident_in_module_unadjusted_ext(
ns
:
Namespace
,
parent_scope
:
&
ParentScope
<
'a
>
,
restricted_shadowing
:
bool
,
finalize
:
Option
<
Span
>
,
finalize
:
Option
<
Finalize
>
,
last_import_segment
:
bool
,
unusable_binding
:
Option
<&
'a
NameBinding
<
'a
>>
,
)
->
Result
<&
'a
NameBinding
<
'a
>
,
(
Determinacy
,
Weak
)
>
{
...
...
@@ -901,7 +900,7 @@ fn resolve_ident_in_module_unadjusted_ext(
let
resolution
=
self
.resolution
(
module
,
key
)
.try_borrow_mut
()
.map_err
(|
_
|
(
Determined
,
Weak
::
No
))
?
;
// This happens when there is a cycle of imports.
if
let
Some
(
path_span
)
=
finalize
{
if
let
Some
(
Finalize
{
path_span
,
..
}
)
=
finalize
{
// If the primary binding is unusable, search further and return the shadowed glob
// binding if it exists. What we really want here is having two separate scopes in
// a module - one for non-globs and one for globs, but until that's done use this
...
...
@@ -1391,13 +1390,12 @@ fn validate_res_from_ribs(
path
:
&
[
Segment
],
opt_ns
:
Option
<
Namespace
>
,
// `None` indicates a module path in import
parent_scope
:
&
ParentScope
<
'a
>
,
finalize
_full
:
Option
<
Finalize
>
,
finalize
:
Option
<
Finalize
>
,
ribs
:
Option
<&
PerNS
<
Vec
<
Rib
<
'a
>>>>
,
unusable_binding
:
Option
<&
'a
NameBinding
<
'a
>>
,
)
->
PathResult
<
'a
>
{
debug!
(
"resolve_path(path={:?}, opt_ns={:?}, finalize={:?})"
,
path
,
opt_ns
,
finalize
_full
);
debug!
(
"resolve_path(path={:?}, opt_ns={:?}, finalize={:?})"
,
path
,
opt_ns
,
finalize
);
let
finalize
=
finalize_full
.map
(|
finalize
|
finalize
.path_span
);
let
mut
module
=
None
;
let
mut
allow_super
=
true
;
let
mut
second_binding
=
None
;
...
...
@@ -1507,7 +1505,7 @@ enum FindBindingResult<'a> {
ident
,
ns
,
parent_scope
,
finalize
_full
,
finalize
,
&
ribs
[
ns
],
unusable_binding
,
)
{
...
...
@@ -1566,7 +1564,7 @@ enum FindBindingResult<'a> {
}
else
if
res
==
Res
::
Err
{
return
PathResult
::
NonModule
(
PartialRes
::
new
(
Res
::
Err
));
}
else
if
opt_ns
.is_some
()
&&
(
is_last
||
maybe_assoc
)
{
self
.lint_if_path_starts_with_module
(
finalize
_full
,
path
,
second_binding
);
self
.lint_if_path_starts_with_module
(
finalize
,
path
,
second_binding
);
return
PathResult
::
NonModule
(
PartialRes
::
with_unresolved_segments
(
res
,
path
.len
()
-
i
-
1
,
...
...
@@ -1609,7 +1607,7 @@ enum FindBindingResult<'a> {
}
}
self
.lint_if_path_starts_with_module
(
finalize
_full
,
path
,
second_binding
);
self
.lint_if_path_starts_with_module
(
finalize
,
path
,
second_binding
);
PathResult
::
Module
(
match
module
{
Some
(
module
)
=>
module
,
...
...
compiler/rustc_resolve/src/imports.rs
浏览文件 @
ffedcec4
...
...
@@ -717,7 +717,7 @@ fn finalize_import(&mut self, import: &'b Import<'b>) -> Option<UnresolvedImport
ident
,
ns
,
&
import
.parent_scope
,
Some
(
import
.span
)
,
finalize
,
true
,
target_bindings
[
ns
]
.get
(),
);
...
...
@@ -778,7 +778,7 @@ fn finalize_import(&mut self, import: &'b Import<'b>) -> Option<UnresolvedImport
ident
,
ns
,
&
import
.parent_scope
,
Some
(
import
.span
)
,
finalize
,
false
,
None
,
);
...
...
compiler/rustc_resolve/src/macros.rs
浏览文件 @
ffedcec4
...
...
@@ -708,7 +708,7 @@ pub fn resolve_macro_path(
ident
,
ScopeSet
::
Macro
(
kind
),
&
parent_scope
,
Some
(
ident
.span
),
Some
(
Finalize
::
new
(
ast
::
CRATE_NODE_ID
,
ident
.span
)
),
true
,
false
,
None
,
...
...
@@ -751,7 +751,7 @@ pub fn resolve_macro_path(
ident
,
ScopeSet
::
Macro
(
MacroKind
::
Attr
),
&
parent_scope
,
Some
(
ident
.span
),
Some
(
Finalize
::
new
(
ast
::
CRATE_NODE_ID
,
ident
.span
)
),
true
,
false
,
None
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录