Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
fc06ea5f
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,发现更多精彩内容 >>
提交
fc06ea5f
编写于
3月 17, 2016
作者:
J
Jeffrey Seyfried
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add a type parameter to ImportDirective
上级
d5a91e69
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
14 addition
and
14 deletion
+14
-14
src/librustc_resolve/lib.rs
src/librustc_resolve/lib.rs
+6
-5
src/librustc_resolve/resolve_imports.rs
src/librustc_resolve/resolve_imports.rs
+8
-9
未找到文件。
src/librustc_resolve/lib.rs
浏览文件 @
fc06ea5f
...
...
@@ -828,7 +828,7 @@ pub struct ModuleS<'a> {
extern_crate_id
:
Option
<
NodeId
>
,
resolutions
:
RefCell
<
HashMap
<
(
Name
,
Namespace
),
NameResolution
<
'a
>>>
,
unresolved_imports
:
RefCell
<
Vec
<&
'a
ImportDirective
>>
,
unresolved_imports
:
RefCell
<
Vec
<&
'a
ImportDirective
<
'a
>
>>
,
// The module children of this node, including normal modules and anonymous modules.
// Anonymous children are pseudo-modules that are implicitly created around items
...
...
@@ -848,7 +848,7 @@ pub struct ModuleS<'a> {
prelude
:
RefCell
<
Option
<
Module
<
'a
>>>
,
glob_importers
:
RefCell
<
Vec
<
(
Module
<
'a
>
,
&
'a
ImportDirective
)
>>
,
glob_importers
:
RefCell
<
Vec
<
(
Module
<
'a
>
,
&
'a
ImportDirective
<
'a
>
)
>>
,
resolved_globs
:
RefCell
<
(
Vec
<
Module
<
'a
>>
/* public */
,
Vec
<
Module
<
'a
>>
/* private */
)
>
,
// The number of public glob imports in this module.
...
...
@@ -891,7 +891,7 @@ fn new(parent_link: ParentLink<'a>,
}
}
fn
add_import_directive
(
&
self
,
import_directive
:
ImportDirective
)
{
fn
add_import_directive
(
&
self
,
import_directive
:
ImportDirective
<
'a
>
)
{
let
import_directive
=
self
.arenas
.alloc_import_directive
(
import_directive
);
self
.unresolved_imports
.borrow_mut
()
.push
(
import_directive
);
}
...
...
@@ -1134,7 +1134,7 @@ pub struct Resolver<'a, 'tcx: 'a> {
struct
ResolverArenas
<
'a
>
{
modules
:
arena
::
TypedArena
<
ModuleS
<
'a
>>
,
name_bindings
:
arena
::
TypedArena
<
NameBinding
<
'a
>>
,
import_directives
:
arena
::
TypedArena
<
ImportDirective
>
,
import_directives
:
arena
::
TypedArena
<
ImportDirective
<
'a
>
>
,
}
impl
<
'a
>
ResolverArenas
<
'a
>
{
...
...
@@ -1144,7 +1144,8 @@ fn alloc_module(&'a self, module: ModuleS<'a>) -> Module<'a> {
fn
alloc_name_binding
(
&
'a
self
,
name_binding
:
NameBinding
<
'a
>
)
->
&
'a
NameBinding
<
'a
>
{
self
.name_bindings
.alloc
(
name_binding
)
}
fn
alloc_import_directive
(
&
'a
self
,
import_directive
:
ImportDirective
)
->
&
'a
ImportDirective
{
fn
alloc_import_directive
(
&
'a
self
,
import_directive
:
ImportDirective
<
'a
>
)
->
&
'a
ImportDirective
{
self
.import_directives
.alloc
(
import_directive
)
}
}
...
...
src/librustc_resolve/resolve_imports.rs
浏览文件 @
fc06ea5f
...
...
@@ -57,7 +57,7 @@ pub fn single(target: Name, source: Name) -> Self {
/// One import directive.
#[derive(Debug,Clone)]
pub
struct
ImportDirective
{
pub
struct
ImportDirective
<
'a
>
{
module_path
:
Vec
<
Name
>
,
subclass
:
ImportDirectiveSubclass
,
span
:
Span
,
...
...
@@ -66,14 +66,14 @@ pub struct ImportDirective {
is_prelude
:
bool
,
}
impl
ImportDirective
{
impl
<
'a
>
ImportDirective
<
'a
>
{
pub
fn
new
(
module_path
:
Vec
<
Name
>
,
subclass
:
ImportDirectiveSubclass
,
span
:
Span
,
id
:
NodeId
,
is_public
:
bool
,
is_prelude
:
bool
)
->
ImportDirective
{
->
Self
{
ImportDirective
{
module_path
:
module_path
,
subclass
:
subclass
,
...
...
@@ -86,9 +86,8 @@ pub fn new(module_path: Vec<Name>,
// Given the binding to which this directive resolves in a particular namespace,
// this returns the binding for the name this directive defines in that namespace.
fn
import
<
'a
>
(
&
self
,
binding
:
&
'a
NameBinding
<
'a
>
,
privacy_error
:
Option
<
Box
<
PrivacyError
<
'a
>>>
)
->
NameBinding
<
'a
>
{
fn
import
(
&
self
,
binding
:
&
'a
NameBinding
<
'a
>
,
privacy_error
:
Option
<
Box
<
PrivacyError
<
'a
>>>
)
->
NameBinding
<
'a
>
{
let
mut
modifiers
=
match
self
.is_public
{
true
=>
DefModifiers
::
PUBLIC
|
DefModifiers
::
IMPORTABLE
,
false
=>
DefModifiers
::
empty
(),
...
...
@@ -292,7 +291,7 @@ fn define_in_glob_importers(&self, name: Name, ns: Namespace, binding: &'a NameB
struct
ImportResolvingError
<
'a
>
{
/// Module where the error happened
source_module
:
Module
<
'a
>
,
import_directive
:
&
'a
ImportDirective
,
import_directive
:
&
'a
ImportDirective
<
'a
>
,
span
:
Span
,
help
:
String
,
}
...
...
@@ -424,7 +423,7 @@ fn resolve_imports_in_current_module(&mut self, errors: &mut Vec<ImportResolving
/// don't know whether the name exists at the moment due to other
/// currently-unresolved imports, or success if we know the name exists.
/// If successful, the resolved bindings are written into the module.
fn
resolve_import
(
&
mut
self
,
directive
:
&
'b
ImportDirective
)
->
ResolveResult
<
()
>
{
fn
resolve_import
(
&
mut
self
,
directive
:
&
'b
ImportDirective
<
'b
>
)
->
ResolveResult
<
()
>
{
debug!
(
"(resolving import for module) resolving import `{}::...` in `{}`"
,
names_to_string
(
&
directive
.module_path
),
module_to_string
(
self
.resolver.current_module
));
...
...
@@ -579,7 +578,7 @@ fn resolve_import(&mut self, directive: &'b ImportDirective) -> ResolveResult<()
// succeeds or bails out (as importing * from an empty module or a module
// that exports nothing is valid). target_module is the module we are
// actually importing, i.e., `foo` in `use foo::*`.
fn
resolve_glob_import
(
&
mut
self
,
target_module
:
Module
<
'b
>
,
directive
:
&
'b
ImportDirective
)
fn
resolve_glob_import
(
&
mut
self
,
target_module
:
Module
<
'b
>
,
directive
:
&
'b
ImportDirective
<
'b
>
)
->
ResolveResult
<
()
>
{
if
let
Some
(
Def
::
Trait
(
_
))
=
target_module
.def
{
self
.resolver.session
.span_err
(
directive
.span
,
"items in traits are not importable."
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录