Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
c64cd86b
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,发现更多精彩内容 >>
提交
c64cd86b
编写于
8月 17, 2016
作者:
J
Jeffrey Seyfried
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add field `parent` to `ImportDirective`.
上级
d107d225
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
11 addition
and
14 deletion
+11
-14
src/librustc_resolve/lib.rs
src/librustc_resolve/lib.rs
+1
-1
src/librustc_resolve/resolve_imports.rs
src/librustc_resolve/resolve_imports.rs
+10
-13
未找到文件。
src/librustc_resolve/lib.rs
浏览文件 @
c64cd86b
...
...
@@ -756,7 +756,7 @@ pub struct ModuleS<'a> {
no_implicit_prelude
:
Cell
<
bool
>
,
glob_importers
:
RefCell
<
Vec
<
(
Module
<
'a
>
,
&
'a
ImportDirective
<
'a
>
)
>>
,
glob_importers
:
RefCell
<
Vec
<
&
'a
ImportDirective
<
'a
>
>>
,
globs
:
RefCell
<
Vec
<&
'a
ImportDirective
<
'a
>>>
,
// Used to memoize the traits in this module for faster searches through all traits in scope.
...
...
src/librustc_resolve/resolve_imports.rs
浏览文件 @
c64cd86b
...
...
@@ -63,6 +63,7 @@ pub fn single(target: Name, source: Name) -> Self {
#[derive(Debug,Clone)]
pub
struct
ImportDirective
<
'a
>
{
pub
id
:
NodeId
,
parent
:
Module
<
'a
>
,
module_path
:
Vec
<
Name
>
,
target_module
:
Cell
<
Option
<
Module
<
'a
>>>
,
// the resolution of `module_path`
subclass
:
ImportDirectiveSubclass
,
...
...
@@ -223,6 +224,7 @@ pub fn add_import_directive(&mut self,
id
:
NodeId
,
vis
:
ty
::
Visibility
)
{
let
directive
=
self
.arenas
.alloc_import_directive
(
ImportDirective
{
parent
:
self
.current_module
,
module_path
:
module_path
,
target_module
:
Cell
::
new
(
None
),
subclass
:
subclass
,
...
...
@@ -306,9 +308,9 @@ fn update_resolution<T, F>(&mut self, module: Module<'a>, name: Name, ns: Namesp
// Define `new_binding` in `module`s glob importers.
if
new_binding
.is_importable
()
&&
new_binding
.is_pseudo_public
()
{
for
&
(
importer
,
directive
)
in
module
.glob_importers
.borrow_mut
()
.iter
()
{
for
directive
in
module
.glob_importers
.borrow_mut
()
.iter
()
{
let
imported_binding
=
self
.import
(
new_binding
,
directive
);
let
_
=
self
.try_define
(
importer
,
name
,
ns
,
imported_binding
);
let
_
=
self
.try_define
(
directive
.parent
,
name
,
ns
,
imported_binding
);
}
}
...
...
@@ -317,8 +319,6 @@ fn update_resolution<T, F>(&mut self, module: Module<'a>, name: Name, ns: Namesp
}
struct
ImportResolvingError
<
'a
>
{
/// Module where the error happened
source_module
:
Module
<
'a
>
,
import_directive
:
&
'a
ImportDirective
<
'a
>
,
span
:
Span
,
help
:
String
,
...
...
@@ -402,9 +402,7 @@ fn resolve_imports(&mut self) {
// Define a "dummy" resolution containing a Def::Err as a placeholder for a
// failed resolution
fn
import_dummy_binding
(
&
mut
self
,
source_module
:
Module
<
'b
>
,
directive
:
&
'b
ImportDirective
<
'b
>
)
{
fn
import_dummy_binding
(
&
mut
self
,
directive
:
&
'b
ImportDirective
<
'b
>
)
{
if
let
SingleImport
{
target
,
..
}
=
directive
.subclass
{
let
dummy_binding
=
self
.arenas
.alloc_name_binding
(
NameBinding
{
kind
:
NameBindingKind
::
Def
(
Def
::
Err
),
...
...
@@ -413,8 +411,8 @@ fn import_dummy_binding(&mut self,
});
let
dummy_binding
=
self
.import
(
dummy_binding
,
directive
);
let
_
=
self
.try_define
(
source_module
,
target
,
ValueNS
,
dummy_binding
.clone
());
let
_
=
self
.try_define
(
source_module
,
target
,
TypeNS
,
dummy_binding
);
let
_
=
self
.try_define
(
directive
.parent
,
target
,
ValueNS
,
dummy_binding
.clone
());
let
_
=
self
.try_define
(
directive
.parent
,
target
,
TypeNS
,
dummy_binding
);
}
}
...
...
@@ -423,7 +421,7 @@ fn import_dummy_binding(&mut self,
fn
import_resolving_error
(
&
mut
self
,
e
:
ImportResolvingError
<
'b
>
)
{
// If the error is a single failed import then create a "fake" import
// resolution for it so that later resolve stages won't complain.
self
.import_dummy_binding
(
e
.
source_module
,
e
.
import_directive
);
self
.import_dummy_binding
(
e
.import_directive
);
let
path
=
import_path_to_string
(
&
e
.import_directive.module_path
,
&
e
.import_directive.subclass
);
resolve_error
(
self
.resolver
,
...
...
@@ -445,7 +443,6 @@ fn resolve_imports_in_current_module(&mut self, errors: &mut Vec<ImportResolving
None
=>
(
import_directive
.span
,
String
::
new
()),
};
errors
.push
(
ImportResolvingError
{
source_module
:
self
.current_module
,
import_directive
:
import_directive
,
span
:
span
,
help
:
help
,
...
...
@@ -511,7 +508,7 @@ fn resolve_import(&mut self, directive: &'b ImportDirective<'b>) -> ResolveResul
.emit
();
// Do not import this illegal binding. Import a dummy binding and pretend
// everything is fine
self
.import_dummy_binding
(
module
,
directive
);
self
.import_dummy_binding
(
directive
);
return
Success
(());
}
Success
(
binding
)
if
!
self
.is_accessible
(
binding
.vis
)
=>
{}
...
...
@@ -635,7 +632,7 @@ fn resolve_glob_import(&mut self, target_module: Module<'b>, directive: &'b Impo
}
// Add to target_module's glob_importers
target_module
.glob_importers
.borrow_mut
()
.push
(
(
module
,
directive
)
);
target_module
.glob_importers
.borrow_mut
()
.push
(
directive
);
// Ensure that `resolutions` isn't borrowed during `try_define`,
// since it might get updated via a glob cycle.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录