Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
58e35d7c
R
Rust
项目概览
int
/
Rust
11 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
58e35d7c
编写于
8月 04, 2015
作者:
V
Victor Berger
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Addressing nits & tests explanations.
上级
f9f9f509
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
34 addition
and
17 deletion
+34
-17
src/librustc_resolve/resolve_imports.rs
src/librustc_resolve/resolve_imports.rs
+22
-15
src/test/run-pass/import-glob-1.rs
src/test/run-pass/import-glob-1.rs
+4
-2
src/test/run-pass/issue-18083.rs
src/test/run-pass/issue-18083.rs
+3
-0
src/test/run-pass/issue-4865-1.rs
src/test/run-pass/issue-4865-1.rs
+5
-0
未找到文件。
src/librustc_resolve/resolve_imports.rs
浏览文件 @
58e35d7c
...
...
@@ -184,6 +184,11 @@ pub fn set_target_and_id(&mut self,
}
}
struct
ImportResolvingError
{
span
:
Span
,
path
:
String
,
help
:
String
,
}
struct
ImportResolver
<
'a
,
'b
:
'a
,
'tcx
:
'b
>
{
resolver
:
&
'a
mut
Resolver
<
'b
,
'tcx
>
...
...
@@ -218,16 +223,16 @@ fn resolve_imports(&mut self) {
if
self
.resolver.unresolved_imports
==
prev_unresolved_imports
{
// resolving failed
if
errors
.len
()
>
0
{
for
(
span
,
path
,
help
)
in
errors
{
for
e
in
errors
{
resolve_error
(
self
.resolver
,
span
,
ResolutionError
::
UnresolvedImport
(
Some
((
&
*
path
,
&*
help
))));
e
.
span
,
ResolutionError
::
UnresolvedImport
(
Some
((
&
e
.path
,
&
e
.
help
))));
}
}
else
{
//
r
eport unresolved imports only if no hard error was already reported
// to avoid generating multiple errors on the same import
//
imports that are still u
ndeterminate at this point are actually blocked
// by errored imports, so there is no point reporting them
//
R
eport unresolved imports only if no hard error was already reported
// to avoid generating multiple errors on the same import
.
//
Imports that are still i
ndeterminate at this point are actually blocked
// by errored imports, so there is no point reporting them
.
self
.resolver
.report_unresolved_imports
(
module_root
);
}
break
;
...
...
@@ -241,7 +246,7 @@ fn resolve_imports(&mut self) {
/// Attempts to resolve imports for the given module and all of its
/// submodules.
fn
resolve_imports_for_module_subtree
(
&
mut
self
,
module_
:
Rc
<
Module
>
)
->
Vec
<
(
Span
,
String
,
String
)
>
{
->
Vec
<
ImportResolvingError
>
{
let
mut
errors
=
Vec
::
new
();
debug!
(
"(resolving imports for module subtree) resolving {}"
,
module_to_string
(
&*
module_
));
...
...
@@ -269,7 +274,7 @@ fn resolve_imports_for_module_subtree(&mut self, module_: Rc<Module>)
}
/// Attempts to resolve imports for the given module only.
fn
resolve_imports_for_module
(
&
mut
self
,
module
:
Rc
<
Module
>
)
->
Vec
<
(
Span
,
String
,
String
)
>
{
fn
resolve_imports_for_module
(
&
mut
self
,
module
:
Rc
<
Module
>
)
->
Vec
<
ImportResolvingError
>
{
let
mut
errors
=
Vec
::
new
();
if
module
.all_imports_resolved
()
{
...
...
@@ -292,12 +297,14 @@ fn resolve_imports_for_module(&mut self, module: Rc<Module>) -> Vec<(Span, Strin
Some
((
span
,
msg
))
=>
(
span
,
format!
(
". {}"
,
msg
)),
None
=>
(
import_directive
.span
,
String
::
new
())
};
errors
.push
((
span
,
import_path_to_string
(
errors
.push
(
ImportResolvingError
{
span
:
span
,
path
:
import_path_to_string
(
&
import_directive
.module_path
,
import_directive
.subclass
),
help
))
help
:
help
});
}
ResolveResult
::
Indeterminate
=>
{}
ResolveResult
::
Success
(())
=>
{
...
...
src/test/run-pass/import-glob-1.rs
浏览文件 @
58e35d7c
// Copyright 201
2-2014
The Rust Project Developers. See the COPYRIGHT
// Copyright 201
5
The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
...
...
@@ -8,7 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![allow(unused_imports,
dead_code)]
// This should resolve fine. Prior to fix, the last import
// was being tried too early, and marked as unrsolved before
// the glob import had a chance to be resolved.
mod
bar
{
pub
use
self
::
middle
::
*
;
...
...
src/test/run-pass/issue-18083.rs
浏览文件 @
58e35d7c
...
...
@@ -8,6 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// These crossed imports should resolve fine, and not block on
// each other and be reported as unresolved.
mod
a
{
use
b
::{
B
};
pub
use
self
::
inner
::
A
;
...
...
src/test/run-pass/issue-4865-1.rs
浏览文件 @
58e35d7c
...
...
@@ -8,6 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// This should resolve fine.
// Prior to fix, the crossed imports between a and b
// would block on the glob import, itself never being resolved
// because these previous imports were not resolved.
pub
mod
a
{
use
b
::
fn_b
;
use
c
::
*
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录