Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
c4803863
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,发现更多精彩内容 >>
提交
c4803863
编写于
9月 11, 2018
作者:
N
Nick Cameron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
dump refs for path segments in save-analysis
Requires adding path segments to the hir map
上级
609d0bd8
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
51 addition
and
20 deletion
+51
-20
src/librustc/hir/lowering.rs
src/librustc/hir/lowering.rs
+1
-0
src/librustc/hir/map/collector.rs
src/librustc/hir/map/collector.rs
+7
-0
src/librustc/hir/map/mod.rs
src/librustc/hir/map/mod.rs
+7
-1
src/librustc/hir/mod.rs
src/librustc/hir/mod.rs
+11
-1
src/librustc/ich/impls_hir.rs
src/librustc/ich/impls_hir.rs
+1
-0
src/librustc_resolve/build_reduced_graph.rs
src/librustc_resolve/build_reduced_graph.rs
+11
-11
src/librustc_resolve/lib.rs
src/librustc_resolve/lib.rs
+6
-3
src/librustc_save_analysis/dump_visitor.rs
src/librustc_save_analysis/dump_visitor.rs
+3
-4
src/librustc_save_analysis/lib.rs
src/librustc_save_analysis/lib.rs
+4
-0
未找到文件。
src/librustc/hir/lowering.rs
浏览文件 @
c4803863
...
...
@@ -1861,6 +1861,7 @@ fn lower_path_segment(
let
def
=
self
.expect_full_def
(
segment
.id
);
hir
::
PathSegment
::
new
(
segment
.ident
,
Some
(
segment
.id
),
Some
(
def
),
generic_args
,
infer_types
,
...
...
src/librustc/hir/map/collector.rs
浏览文件 @
c4803863
...
...
@@ -392,6 +392,13 @@ fn visit_stmt(&mut self, stmt: &'hir Stmt) {
});
}
fn
visit_path_segment
(
&
mut
self
,
path_span
:
Span
,
path_segment
:
&
'hir
PathSegment
)
{
if
let
Some
(
id
)
=
path_segment
.id
{
self
.insert
(
id
,
Node
::
PathSegment
(
path_segment
));
}
intravisit
::
walk_path_segment
(
self
,
path_span
,
path_segment
);
}
fn
visit_ty
(
&
mut
self
,
ty
:
&
'hir
Ty
)
{
self
.insert
(
ty
.id
,
Node
::
Ty
(
ty
));
...
...
src/librustc/hir/map/mod.rs
浏览文件 @
c4803863
...
...
@@ -204,7 +204,7 @@ pub fn read(&self, id: NodeId) {
if
let
Some
(
entry
)
=
self
.map
[
id
.as_usize
()]
{
self
.dep_graph
.read_index
(
entry
.dep_node
);
}
else
{
bug!
(
"called `HirMap::read()` with invalid `NodeId`
"
)
bug!
(
"called `HirMap::read()` with invalid `NodeId`
: {:?}"
,
id
)
}
}
...
...
@@ -344,6 +344,7 @@ pub fn describe_def(&self, node_id: NodeId) -> Option<Def> {
Node
::
AnonConst
(
_
)
|
Node
::
Expr
(
_
)
|
Node
::
Stmt
(
_
)
|
Node
::
PathSegment
(
_
)
|
Node
::
Ty
(
_
)
|
Node
::
TraitRef
(
_
)
|
Node
::
Pat
(
_
)
|
...
...
@@ -884,6 +885,7 @@ pub fn span(&self, id: NodeId) -> Span {
Some
(
Node
::
AnonConst
(
constant
))
=>
self
.body
(
constant
.body
)
.value.span
,
Some
(
Node
::
Expr
(
expr
))
=>
expr
.span
,
Some
(
Node
::
Stmt
(
stmt
))
=>
stmt
.span
,
Some
(
Node
::
PathSegment
(
seg
))
=>
seg
.ident.span
,
Some
(
Node
::
Ty
(
ty
))
=>
ty
.span
,
Some
(
Node
::
TraitRef
(
tr
))
=>
tr
.path.span
,
Some
(
Node
::
Binding
(
pat
))
=>
pat
.span
,
...
...
@@ -1098,6 +1100,7 @@ pub fn print_node(&mut self, node: Node<'_>) -> io::Result<()> {
Node
::
AnonConst
(
a
)
=>
self
.print_anon_const
(
&
a
),
Node
::
Expr
(
a
)
=>
self
.print_expr
(
&
a
),
Node
::
Stmt
(
a
)
=>
self
.print_stmt
(
&
a
),
Node
::
PathSegment
(
_
)
=>
bug!
(
"cannot print PathSegment"
),
Node
::
Ty
(
a
)
=>
self
.print_type
(
&
a
),
Node
::
TraitRef
(
a
)
=>
self
.print_trait_ref
(
&
a
),
Node
::
Binding
(
a
)
|
...
...
@@ -1215,6 +1218,9 @@ fn node_id_to_string(map: &Map<'_>, id: NodeId, include_id: bool) -> String {
Some
(
Node
::
Stmt
(
_
))
=>
{
format!
(
"stmt {}{}"
,
map
.node_to_pretty_string
(
id
),
id_str
)
}
Some
(
Node
::
PathSegment
(
_
))
=>
{
format!
(
"path segment {}{}"
,
map
.node_to_pretty_string
(
id
),
id_str
)
}
Some
(
Node
::
Ty
(
_
))
=>
{
format!
(
"type {}{}"
,
map
.node_to_pretty_string
(
id
),
id_str
)
}
...
...
src/librustc/hir/mod.rs
浏览文件 @
c4803863
...
...
@@ -347,6 +347,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
pub
struct
PathSegment
{
/// The identifier portion of this path segment.
pub
ident
:
Ident
,
pub
id
:
Option
<
NodeId
>
,
pub
def
:
Option
<
Def
>
,
/// Type/lifetime parameters attached to this path. They come in
...
...
@@ -368,15 +369,23 @@ impl PathSegment {
pub
fn
from_ident
(
ident
:
Ident
)
->
PathSegment
{
PathSegment
{
ident
,
id
:
None
,
def
:
None
,
infer_types
:
true
,
args
:
None
,
}
}
pub
fn
new
(
ident
:
Ident
,
def
:
Option
<
Def
>
,
args
:
GenericArgs
,
infer_types
:
bool
)
->
Self
{
pub
fn
new
(
ident
:
Ident
,
id
:
Option
<
NodeId
>
,
def
:
Option
<
Def
>
,
args
:
GenericArgs
,
infer_types
:
bool
,
)
->
Self
{
PathSegment
{
ident
,
id
,
def
,
infer_types
,
args
:
if
args
.is_empty
()
{
...
...
@@ -2514,6 +2523,7 @@ pub enum Node<'hir> {
AnonConst
(
&
'hir
AnonConst
),
Expr
(
&
'hir
Expr
),
Stmt
(
&
'hir
Stmt
),
PathSegment
(
&
'hir
PathSegment
),
Ty
(
&
'hir
Ty
),
TraitRef
(
&
'hir
TraitRef
),
Binding
(
&
'hir
Pat
),
...
...
src/librustc/ich/impls_hir.rs
浏览文件 @
c4803863
...
...
@@ -174,6 +174,7 @@ fn hash_stable<W: StableHasherResult>(&self,
impl_stable_hash_for!
(
struct
hir
::
PathSegment
{
ident
->
(
ident
.name
),
id
,
def
,
infer_types
,
args
...
...
src/librustc_resolve/build_reduced_graph.rs
浏览文件 @
c4803863
...
...
@@ -392,18 +392,18 @@ fn build_reduced_graph_for_use_tree(
e
.emit
();
}
for
&
(
ref
tree
,
id
)
in
items
{
let
prefix
=
ast
::
Path
{
segments
:
module_path
.iter
()
.map
(|
ident
|
{
let
mut
seg
=
ast
::
PathSegment
::
from_ident
(
ident
.0
);
seg
.id
=
self
.session
.next_node_id
();
seg
})
.collect
(),
span
:
path
.span
,
};
let
prefix
=
ast
::
Path
{
segments
:
module_path
.into_iter
()
.map
(|(
ident
,
id
)|
{
let
mut
seg
=
ast
::
PathSegment
::
from_ident
(
ident
);
seg
.id
=
id
.expect
(
"Missing node id"
);
seg
})
.collect
(),
span
:
path
.span
,
};
for
&
(
ref
tree
,
id
)
in
items
{
self
.build_reduced_graph_for_use_tree
(
root_use_tree
,
root_id
,
...
...
src/librustc_resolve/lib.rs
浏览文件 @
c4803863
...
...
@@ -3614,6 +3614,7 @@ fn resolve_path_with_parent_scope(
for
(
i
,
&
(
ident
,
id
))
in
path
.iter
()
.enumerate
()
{
debug!
(
"resolve_path ident {} {:?}"
,
i
,
ident
);
let
is_last
=
i
==
path
.len
()
-
1
;
let
ns
=
if
is_last
{
opt_ns
.unwrap_or
(
TypeNS
)
}
else
{
TypeNS
};
let
name
=
ident
.name
;
...
...
@@ -3713,10 +3714,12 @@ fn resolve_path_with_parent_scope(
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
!
is_last
&&
record_used
{
if
record_used
{
if
let
Some
(
id
)
=
id
{
assert
!
(
id
!=
ast
::
DUMMY_NODE_ID
,
"Trying to resolve dummy id"
);
self
.record_def
(
id
,
PathResolution
::
new
(
def
));
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
));
}
}
}
}
else
if
def
==
Def
::
ToolMod
&&
i
+
1
!=
path
.len
()
{
...
...
src/librustc_save_analysis/dump_visitor.rs
浏览文件 @
c4803863
...
...
@@ -812,9 +812,8 @@ fn process_struct_lit(
variant
:
&
'l
ty
::
VariantDef
,
base
:
&
'l
Option
<
P
<
ast
::
Expr
>>
,
)
{
self
.write_sub_paths_truncated
(
path
);
if
let
Some
(
struct_lit_data
)
=
self
.save_ctxt
.get_expr_data
(
ex
)
{
self
.write_sub_paths_truncated
(
path
);
down_cast_data!
(
struct_lit_data
,
RefData
,
ex
.span
);
if
!
generated_code
(
ex
.span
)
{
self
.dumper
.dump_ref
(
struct_lit_data
);
...
...
@@ -1232,8 +1231,8 @@ fn process_use_tree(&mut self,
value
:
String
::
new
(),
parent
,
});
self
.write_sub_paths_truncated
(
&
path
);
}
self
.write_sub_paths_truncated
(
&
path
);
}
ast
::
UseTreeKind
::
Glob
=>
{
let
path
=
ast
::
Path
{
...
...
@@ -1268,8 +1267,8 @@ fn process_use_tree(&mut self,
value
:
names
.join
(
", "
),
parent
,
});
self
.write_sub_paths
(
&
path
);
}
self
.write_sub_paths
(
&
path
);
}
ast
::
UseTreeKind
::
Nested
(
ref
nested_items
)
=>
{
let
prefix
=
ast
::
Path
{
...
...
src/librustc_save_analysis/lib.rs
浏览文件 @
c4803863
...
...
@@ -632,6 +632,10 @@ pub fn get_path_def(&self, id: NodeId) -> HirDef {
Node
::
Visibility
(
&
Spanned
{
node
:
hir
::
VisibilityKind
::
Restricted
{
ref
path
,
..
},
..
})
=>
path
.def
,
Node
::
PathSegment
(
seg
)
=>
match
seg
.def
{
Some
(
def
)
=>
def
,
None
=>
HirDef
::
Err
,
},
Node
::
Expr
(
&
hir
::
Expr
{
node
:
hir
::
ExprKind
::
Struct
(
ref
qpath
,
..
),
..
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录