Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
56ace0aa
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,发现更多精彩内容 >>
提交
56ace0aa
编写于
4月 19, 2018
作者:
M
Manish Goregaokar
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Pass down NodeId to resolve_path
上级
8830a030
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
19 addition
and
13 deletion
+19
-13
src/librustc_resolve/lib.rs
src/librustc_resolve/lib.rs
+12
-8
src/librustc_resolve/macros.rs
src/librustc_resolve/macros.rs
+2
-2
src/librustc_resolve/resolve_imports.rs
src/librustc_resolve/resolve_imports.rs
+5
-3
未找到文件。
src/librustc_resolve/lib.rs
浏览文件 @
56ace0aa
...
...
@@ -1654,11 +1654,12 @@ fn resolve_hir_path_cb<F>(&mut self, path: &mut hir::Path, is_value: bool, error
let
path
:
Vec
<
Ident
>
=
segments
.iter
()
.map
(|
seg
|
Ident
::
new
(
seg
.name
,
span
))
.collect
();
match
self
.resolve_path
(
&
path
,
Some
(
namespace
),
true
,
span
)
{
// FIXME (Manishearth): Intra doc links won't get warned of epoch changes
match
self
.resolve_path
(
&
path
,
Some
(
namespace
),
true
,
span
,
None
)
{
PathResult
::
Module
(
module
)
=>
*
def
=
module
.def
()
.unwrap
(),
PathResult
::
NonModule
(
path_res
)
if
path_res
.unresolved_segments
()
==
0
=>
*
def
=
path_res
.base_def
(),
PathResult
::
NonModule
(
..
)
=>
match
self
.resolve_path
(
&
path
,
None
,
true
,
span
)
{
PathResult
::
NonModule
(
..
)
=>
match
self
.resolve_path
(
&
path
,
None
,
true
,
span
,
None
)
{
PathResult
::
Failed
(
span
,
msg
,
_
)
=>
{
error_callback
(
self
,
span
,
ResolutionError
::
FailedToResolve
(
&
msg
));
}
...
...
@@ -2360,7 +2361,8 @@ fn with_optional_trait_ref<T, F>(&mut self, opt_trait_ref: Option<&TraitRef>, f:
if
def
!=
Def
::
Err
{
new_id
=
Some
(
def
.def_id
());
let
span
=
trait_ref
.path.span
;
if
let
PathResult
::
Module
(
module
)
=
self
.resolve_path
(
&
path
,
None
,
false
,
span
)
{
if
let
PathResult
::
Module
(
module
)
=
self
.resolve_path
(
&
path
,
None
,
false
,
span
,
Some
(
trait_ref
.ref_id
))
{
new_val
=
Some
((
module
,
trait_ref
.clone
()));
}
}
...
...
@@ -2819,7 +2821,8 @@ fn smart_resolve_path_fragment(&mut self,
(
format!
(
""
),
format!
(
"the crate root"
))
}
else
{
let
mod_path
=
&
path
[
..
path
.len
()
-
1
];
let
mod_prefix
=
match
this
.resolve_path
(
mod_path
,
Some
(
TypeNS
),
false
,
span
)
{
let
mod_prefix
=
match
this
.resolve_path
(
mod_path
,
Some
(
TypeNS
),
false
,
span
,
None
)
{
PathResult
::
Module
(
module
)
=>
module
.def
(),
_
=>
None
,
}
.map_or
(
format!
(
""
),
|
def
|
format!
(
"{} "
,
def
.kind_name
()));
...
...
@@ -3149,7 +3152,7 @@ fn resolve_qpath(&mut self,
));
}
let
result
=
match
self
.resolve_path
(
&
path
,
Some
(
ns
),
true
,
span
)
{
let
result
=
match
self
.resolve_path
(
&
path
,
Some
(
ns
),
true
,
span
,
Some
(
id
)
)
{
PathResult
::
NonModule
(
path_res
)
=>
path_res
,
PathResult
::
Module
(
module
)
if
!
module
.is_normal
()
=>
{
PathResolution
::
new
(
module
.def
()
.unwrap
())
...
...
@@ -3186,7 +3189,7 @@ fn resolve_qpath(&mut self,
path
[
0
]
.name
!=
keywords
::
CrateRoot
.name
()
&&
path
[
0
]
.name
!=
keywords
::
DollarCrate
.name
()
{
let
unqualified_result
=
{
match
self
.resolve_path
(
&
[
*
path
.last
()
.unwrap
()],
Some
(
ns
),
false
,
span
)
{
match
self
.resolve_path
(
&
[
*
path
.last
()
.unwrap
()],
Some
(
ns
),
false
,
span
,
Some
(
id
)
)
{
PathResult
::
NonModule
(
path_res
)
=>
path_res
.base_def
(),
PathResult
::
Module
(
module
)
=>
module
.def
()
.unwrap
(),
_
=>
return
Some
(
result
),
...
...
@@ -3205,7 +3208,8 @@ fn resolve_path(&mut self,
path
:
&
[
Ident
],
opt_ns
:
Option
<
Namespace
>
,
// `None` indicates a module path
record_used
:
bool
,
path_span
:
Span
)
path_span
:
Span
,
_
node_id
:
Option
<
NodeId
>
)
->
PathResult
<
'a
>
{
let
mut
module
=
None
;
let
mut
allow_super
=
true
;
...
...
@@ -3571,7 +3575,7 @@ fn lookup_typo_candidate<FilterFn>(&mut self,
// Search in module.
let
mod_path
=
&
path
[
..
path
.len
()
-
1
];
if
let
PathResult
::
Module
(
module
)
=
self
.resolve_path
(
mod_path
,
Some
(
TypeNS
),
false
,
span
)
{
false
,
span
,
None
)
{
add_module_candidates
(
module
,
&
mut
names
);
}
}
...
...
src/librustc_resolve/macros.rs
浏览文件 @
56ace0aa
...
...
@@ -426,7 +426,7 @@ pub fn resolve_macro_to_def_inner(&mut self, scope: Mark, path: &ast::Path,
return
Err
(
Determinacy
::
Determined
);
}
let
def
=
match
self
.resolve_path
(
&
path
,
Some
(
MacroNS
),
false
,
span
)
{
let
def
=
match
self
.resolve_path
(
&
path
,
Some
(
MacroNS
),
false
,
span
,
None
)
{
PathResult
::
NonModule
(
path_res
)
=>
match
path_res
.base_def
()
{
Def
::
Err
=>
Err
(
Determinacy
::
Determined
),
def
@
_
=>
{
...
...
@@ -604,7 +604,7 @@ pub fn resolve_legacy_scope(&mut self,
pub
fn
finalize_current_module_macro_resolutions
(
&
mut
self
)
{
let
module
=
self
.current_module
;
for
&
(
ref
path
,
span
)
in
module
.macro_resolutions
.borrow
()
.iter
()
{
match
self
.resolve_path
(
&
path
,
Some
(
MacroNS
),
true
,
span
)
{
match
self
.resolve_path
(
&
path
,
Some
(
MacroNS
),
true
,
span
,
None
)
{
PathResult
::
NonModule
(
_
)
=>
{},
PathResult
::
Failed
(
span
,
msg
,
_
)
=>
{
resolve_error
(
self
,
span
,
ResolutionError
::
FailedToResolve
(
&
msg
));
...
...
src/librustc_resolve/resolve_imports.rs
浏览文件 @
56ace0aa
...
...
@@ -535,7 +535,8 @@ fn resolve_import(&mut self, directive: &'b ImportDirective<'b>) -> bool {
// For better failure detection, pretend that the import will not define any names
// while resolving its module path.
directive
.vis
.set
(
ty
::
Visibility
::
Invisible
);
let
result
=
self
.resolve_path
(
&
directive
.module_path
[
..
],
None
,
false
,
directive
.span
);
let
result
=
self
.resolve_path
(
&
directive
.module_path
[
..
],
None
,
false
,
directive
.span
,
Some
(
directive
.id
));
directive
.vis
.set
(
vis
);
match
result
{
...
...
@@ -663,7 +664,7 @@ fn finalize_import(&mut self, directive: &'b ImportDirective<'b>) -> Option<(Spa
}
}
let
module_result
=
self
.resolve_path
(
&
module_path
,
None
,
true
,
span
);
let
module_result
=
self
.resolve_path
(
&
module_path
,
None
,
true
,
span
,
Some
(
directive
.id
)
);
let
module
=
match
module_result
{
PathResult
::
Module
(
module
)
=>
module
,
PathResult
::
Failed
(
span
,
msg
,
false
)
=>
{
...
...
@@ -677,7 +678,8 @@ fn finalize_import(&mut self, directive: &'b ImportDirective<'b>) -> Option<(Spa
if
!
self_path
.is_empty
()
&&
!
is_special
(
self_path
[
0
])
&&
!
(
self_path
.len
()
>
1
&&
is_special
(
self_path
[
1
]))
{
self_path
[
0
]
.name
=
keywords
::
SelfValue
.name
();
self_result
=
Some
(
self
.resolve_path
(
&
self_path
,
None
,
false
,
span
));
self_result
=
Some
(
self
.resolve_path
(
&
self_path
,
None
,
false
,
span
,
Some
(
directive
.id
)));
}
return
if
let
Some
(
PathResult
::
Module
(
..
))
=
self_result
{
Some
((
span
,
format!
(
"Did you mean `{}`?"
,
names_to_string
(
&
self_path
[
..
]))))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录