Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
4895deae
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,发现更多精彩内容 >>
提交
4895deae
编写于
10月 31, 2018
作者:
N
Nick Cameron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
save-analysis: make sure we save the def for the last segment of a path
上级
f586ac9e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
18 addition
and
18 deletion
+18
-18
src/librustc/hir/lowering.rs
src/librustc/hir/lowering.rs
+4
-7
src/librustc_resolve/lib.rs
src/librustc_resolve/lib.rs
+13
-9
src/librustc_save_analysis/dump_visitor.rs
src/librustc_save_analysis/dump_visitor.rs
+1
-2
未找到文件。
src/librustc/hir/lowering.rs
浏览文件 @
4895deae
...
...
@@ -1754,7 +1754,6 @@ fn lower_path_extra(
&
mut
self
,
def
:
Def
,
p
:
&
Path
,
ident
:
Option
<
Ident
>
,
param_mode
:
ParamMode
,
explicit_owner
:
Option
<
NodeId
>
,
)
->
hir
::
Path
{
...
...
@@ -1773,7 +1772,6 @@ fn lower_path_extra(
explicit_owner
,
)
})
.chain
(
ident
.map
(|
ident
|
hir
::
PathSegment
::
from_ident
(
ident
)))
.collect
(),
span
:
p
.span
,
}
...
...
@@ -1781,7 +1779,7 @@ fn lower_path_extra(
fn
lower_path
(
&
mut
self
,
id
:
NodeId
,
p
:
&
Path
,
param_mode
:
ParamMode
)
->
hir
::
Path
{
let
def
=
self
.expect_full_def
(
id
);
self
.lower_path_extra
(
def
,
p
,
None
,
param_mode
,
None
)
self
.lower_path_extra
(
def
,
p
,
param_mode
,
None
)
}
fn
lower_path_segment
(
...
...
@@ -3014,7 +3012,7 @@ fn lower_use_tree(
self
.with_hir_id_owner
(
new_node_id
,
|
this
|
{
let
new_id
=
this
.lower_node_id
(
new_node_id
);
let
path
=
this
.lower_path_extra
(
def
,
&
path
,
None
,
ParamMode
::
Explicit
,
None
);
this
.lower_path_extra
(
def
,
&
path
,
ParamMode
::
Explicit
,
None
);
let
item
=
hir
::
ItemKind
::
Use
(
P
(
path
),
hir
::
UseKind
::
Single
);
let
vis_kind
=
match
vis
.node
{
hir
::
VisibilityKind
::
Public
=>
hir
::
VisibilityKind
::
Public
,
...
...
@@ -3053,7 +3051,7 @@ fn lower_use_tree(
}
let
path
=
P
(
self
.lower_path_extra
(
ret_def
,
&
path
,
None
,
ParamMode
::
Explicit
,
None
));
P
(
self
.lower_path_extra
(
ret_def
,
&
path
,
ParamMode
::
Explicit
,
None
));
hir
::
ItemKind
::
Use
(
path
,
hir
::
UseKind
::
Single
)
}
UseTreeKind
::
Glob
=>
{
...
...
@@ -3140,7 +3138,7 @@ fn lower_use_tree(
// the stability of `use a::{};`, to avoid it showing up as
// a re-export by accident when `pub`, e.g. in documentation.
let
def
=
self
.expect_full_def_from_use
(
id
)
.next
()
.unwrap_or
(
Def
::
Err
);
let
path
=
P
(
self
.lower_path_extra
(
def
,
&
prefix
,
None
,
ParamMode
::
Explicit
,
None
));
let
path
=
P
(
self
.lower_path_extra
(
def
,
&
prefix
,
ParamMode
::
Explicit
,
None
));
*
vis
=
respan
(
prefix
.span
.shrink_to_lo
(),
hir
::
VisibilityKind
::
Inherited
);
hir
::
ItemKind
::
Use
(
path
,
hir
::
UseKind
::
ListStem
)
}
...
...
@@ -4550,7 +4548,6 @@ fn lower_visibility(
path
:
P
(
self
.lower_path_extra
(
def
,
path
,
None
,
ParamMode
::
Explicit
,
explicit_owner
,
)),
...
...
src/librustc_resolve/lib.rs
浏览文件 @
4895deae
...
...
@@ -3589,7 +3589,17 @@ fn resolve_path(
);
for
(
i
,
&
Segment
{
ident
,
id
})
in
path
.iter
()
.enumerate
()
{
debug!
(
"resolve_path ident {} {:?}"
,
i
,
ident
);
debug!
(
"resolve_path ident {} {:?} {:?}"
,
i
,
ident
,
id
);
let
record_segment_def
=
|
this
:
&
mut
Self
,
def
|
{
if
record_used
{
if
let
Some
(
id
)
=
id
{
if
!
this
.def_map
.contains_key
(
&
id
)
{
assert
!
(
id
!=
ast
::
DUMMY_NODE_ID
,
"Trying to resolve dummy id"
);
this
.record_def
(
id
,
PathResolution
::
new
(
def
));
}
}
}
};
let
is_last
=
i
==
path
.len
()
-
1
;
let
ns
=
if
is_last
{
opt_ns
.unwrap_or
(
TypeNS
)
}
else
{
TypeNS
};
...
...
@@ -3673,6 +3683,7 @@ fn resolve_path(
// we found a local variable or type param
Some
(
LexicalScopeBinding
::
Def
(
def
))
if
opt_ns
==
Some
(
TypeNS
)
||
opt_ns
==
Some
(
ValueNS
)
=>
{
record_segment_def
(
self
,
def
);
return
PathResult
::
NonModule
(
PathResolution
::
with_unresolved_segments
(
def
,
path
.len
()
-
1
));
...
...
@@ -3690,14 +3701,7 @@ fn resolve_path(
let
maybe_assoc
=
opt_ns
!=
Some
(
MacroNS
)
&&
PathSource
::
Type
.is_expected
(
def
);
if
let
Some
(
next_module
)
=
binding
.module
()
{
module
=
Some
(
ModuleOrUniformRoot
::
Module
(
next_module
));
if
record_used
{
if
let
Some
(
id
)
=
id
{
if
!
self
.def_map
.contains_key
(
&
id
)
{
assert
!
(
id
!=
ast
::
DUMMY_NODE_ID
,
"Trying to resolve dummy id"
);
self
.record_def
(
id
,
PathResolution
::
new
(
def
));
}
}
}
record_segment_def
(
self
,
def
);
}
else
if
def
==
Def
::
ToolMod
&&
i
+
1
!=
path
.len
()
{
let
def
=
Def
::
NonMacroAttr
(
NonMacroAttrKind
::
Tool
);
return
PathResult
::
NonModule
(
PathResolution
::
new
(
def
));
...
...
src/librustc_save_analysis/dump_visitor.rs
浏览文件 @
4895deae
...
...
@@ -771,8 +771,7 @@ fn dump_path_ref(&mut self, id: NodeId, path: &ast::Path) {
}
fn
process_path
(
&
mut
self
,
id
:
NodeId
,
path
:
&
'l
ast
::
Path
)
{
debug!
(
"process_path {:?}"
,
path
);
if
generated_code
(
path
.span
)
{
if
self
.span
.filter_generated
(
path
.span
)
{
return
;
}
self
.dump_path_ref
(
id
,
path
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录