Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
888a9681
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,发现更多精彩内容 >>
提交
888a9681
编写于
9月 05, 2016
作者:
J
Jeffrey Seyfried
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add field `used: Cell<bool>` to variant `NameBindingKind::Import`.
上级
07f8cb28
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
17 addition
and
22 deletion
+17
-22
src/librustc_resolve/lib.rs
src/librustc_resolve/lib.rs
+16
-22
src/librustc_resolve/resolve_imports.rs
src/librustc_resolve/resolve_imports.rs
+1
-0
未找到文件。
src/librustc_resolve/lib.rs
浏览文件 @
888a9681
...
...
@@ -871,6 +871,7 @@ enum NameBindingKind<'a> {
Import
{
binding
:
&
'a
NameBinding
<
'a
>
,
directive
:
&
'a
ImportDirective
<
'a
>
,
used
:
Cell
<
bool
>
,
},
Ambiguity
{
b1
:
&
'a
NameBinding
<
'a
>
,
...
...
@@ -938,14 +939,6 @@ fn is_importable(&self) -> bool {
_
=>
true
,
}
}
fn
ambiguity
(
&
self
)
->
Option
<
(
&
'a
NameBinding
<
'a
>
,
&
'a
NameBinding
<
'a
>
)
>
{
match
self
.kind
{
NameBindingKind
::
Ambiguity
{
b1
,
b2
}
=>
Some
((
b1
,
b2
)),
NameBindingKind
::
Import
{
binding
,
..
}
=>
binding
.ambiguity
(),
_
=>
None
,
}
}
}
/// Interns the names of the primitive types.
...
...
@@ -1064,7 +1057,7 @@ pub struct Resolver<'a> {
pub
maybe_unused_trait_imports
:
NodeSet
,
privacy_errors
:
Vec
<
PrivacyError
<
'a
>>
,
ambiguity_errors
:
Vec
<
(
Span
,
Name
,
&
'a
NameBinding
<
'a
>
)
>
,
ambiguity_errors
:
Vec
<
(
Span
,
Name
,
&
'a
NameBinding
<
'a
>
,
&
'a
NameBinding
<
'a
>
)
>
,
arenas
:
&
'a
ResolverArenas
<
'a
>
,
dummy_binding
:
&
'a
NameBinding
<
'a
>
,
...
...
@@ -1276,18 +1269,20 @@ fn record_use(&mut self, name: Name, ns: Namespace, binding: &'a NameBinding<'a>
self
.used_crates
.insert
(
krate
);
}
if
binding
.ambiguity
()
.is_some
()
{
self
.ambiguity_errors
.push
((
span
,
name
,
binding
));
return
true
;
}
if
let
NameBindingKind
::
Import
{
directive
,
binding
}
=
binding
.kind
{
self
.used_imports
.insert
((
directive
.id
,
ns
));
self
.add_to_glob_map
(
directive
.id
,
name
);
self
.record_use
(
name
,
ns
,
binding
,
span
);
match
binding
.kind
{
NameBindingKind
::
Import
{
directive
,
binding
,
ref
used
}
if
!
used
.get
()
=>
{
used
.set
(
true
);
self
.used_imports
.insert
((
directive
.id
,
ns
));
self
.add_to_glob_map
(
directive
.id
,
name
);
self
.record_use
(
name
,
ns
,
binding
,
span
)
}
NameBindingKind
::
Import
{
..
}
=>
false
,
NameBindingKind
::
Ambiguity
{
b1
,
b2
}
=>
{
self
.ambiguity_errors
.push
((
span
,
name
,
b1
,
b2
));
true
}
_
=>
false
}
false
}
fn
add_to_glob_map
(
&
mut
self
,
id
:
NodeId
,
name
:
Name
)
{
...
...
@@ -3307,9 +3302,8 @@ fn is_accessible_from(&self, vis: ty::Visibility, module: Module<'a>) -> bool {
fn
report_errors
(
&
self
)
{
let
mut
reported_spans
=
FnvHashSet
();
for
&
(
span
,
name
,
b
inding
)
in
&
self
.ambiguity_errors
{
for
&
(
span
,
name
,
b
1
,
b2
)
in
&
self
.ambiguity_errors
{
if
!
reported_spans
.insert
(
span
)
{
continue
}
let
(
b1
,
b2
)
=
binding
.ambiguity
()
.unwrap
();
let
msg1
=
format!
(
"`{}` could resolve to the name imported here"
,
name
);
let
msg2
=
format!
(
"`{}` could also resolve to the name imported here"
,
name
);
self
.session
.struct_span_err
(
span
,
&
format!
(
"`{}` is ambiguous"
,
name
))
...
...
src/librustc_resolve/resolve_imports.rs
浏览文件 @
888a9681
...
...
@@ -308,6 +308,7 @@ fn import(&mut self, binding: &'a NameBinding<'a>, directive: &'a ImportDirectiv
kind
:
NameBindingKind
::
Import
{
binding
:
binding
,
directive
:
directive
,
used
:
Cell
::
new
(
false
),
},
span
:
directive
.span
,
vis
:
vis
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录