Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
2d74e9ba
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,发现更多精彩内容 >>
提交
2d74e9ba
编写于
12月 04, 2019
作者:
C
Camille GILLOT
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Allocate inside lower_path_extra.
上级
e569ada5
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
20 addition
and
38 deletion
+20
-38
src/librustc/hir/lowering.rs
src/librustc/hir/lowering.rs
+10
-14
src/librustc/hir/lowering/expr.rs
src/librustc/hir/lowering/expr.rs
+3
-7
src/librustc/hir/lowering/item.rs
src/librustc/hir/lowering/item.rs
+7
-17
未找到文件。
src/librustc/hir/lowering.rs
浏览文件 @
2d74e9ba
...
...
@@ -1800,8 +1800,8 @@ fn lower_path_extra(
p
:
&
Path
,
param_mode
:
ParamMode
,
explicit_owner
:
Option
<
NodeId
>
,
)
->
hir
::
Path
<
'hir
>
{
hir
::
Path
{
)
->
&
'hir
hir
::
Path
<
'hir
>
{
self
.arena
.alloc
(
hir
::
Path
{
res
,
segments
:
self
.arena
.alloc_from_iter
(
p
.segments
.iter
()
.map
(|
segment
|
{
self
.lower_path_segment
(
...
...
@@ -1815,10 +1815,10 @@ fn lower_path_extra(
)
})),
span
:
p
.span
,
}
}
)
}
fn
lower_path
(
&
mut
self
,
id
:
NodeId
,
p
:
&
Path
,
param_mode
:
ParamMode
)
->
hir
::
Path
<
'hir
>
{
fn
lower_path
(
&
mut
self
,
id
:
NodeId
,
p
:
&
Path
,
param_mode
:
ParamMode
)
->
&
'hir
hir
::
Path
<
'hir
>
{
let
res
=
self
.expect_full_res
(
id
);
let
res
=
self
.lower_res
(
res
);
self
.lower_path_extra
(
res
,
p
,
param_mode
,
None
)
...
...
@@ -2396,12 +2396,8 @@ fn lower_async_fn_output_type_to_future_bound(
});
// ::std::future::Future<future_params>
let
future_path
=
self
.arena
.alloc
(
self
.std_path
(
span
,
&
[
sym
::
future
,
sym
::
Future
],
Some
(
future_params
),
false
,
));
let
future_path
=
self
.std_path
(
span
,
&
[
sym
::
future
,
sym
::
Future
],
Some
(
future_params
),
false
);
hir
::
GenericBound
::
Trait
(
hir
::
PolyTraitRef
{
...
...
@@ -3048,7 +3044,7 @@ fn pat_std_enum(
subpats
:
&
'hir
[
&
'hir
hir
::
Pat
<
'hir
>
],
)
->
&
'hir
hir
::
Pat
<
'hir
>
{
let
path
=
self
.std_path
(
span
,
components
,
None
,
true
);
let
qpath
=
hir
::
QPath
::
Resolved
(
None
,
self
.arena
.alloc
(
path
)
);
let
qpath
=
hir
::
QPath
::
Resolved
(
None
,
path
);
let
pt
=
if
subpats
.is_empty
()
{
hir
::
PatKind
::
Path
(
qpath
)
}
else
{
...
...
@@ -3096,7 +3092,7 @@ fn std_path(
components
:
&
[
Symbol
],
params
:
Option
<&
'hir
hir
::
GenericArgs
<
'hir
>>
,
is_value
:
bool
,
)
->
hir
::
Path
<
'hir
>
{
)
->
&
'hir
hir
::
Path
<
'hir
>
{
let
ns
=
if
is_value
{
Namespace
::
ValueNS
}
else
{
Namespace
::
TypeNS
};
let
(
path
,
res
)
=
self
.resolver
.resolve_str_path
(
span
,
self
.crate_root
,
components
,
ns
);
...
...
@@ -3116,11 +3112,11 @@ fn std_path(
.collect
();
segments
.last_mut
()
.unwrap
()
.args
=
params
;
hir
::
Path
{
self
.arena
.alloc
(
hir
::
Path
{
span
,
res
:
res
.map_id
(|
_
|
panic!
(
"unexpected `NodeId`"
)),
segments
:
self
.arena
.alloc_from_iter
(
segments
),
}
}
)
}
fn
ty_path
(
...
...
src/librustc/hir/lowering/expr.rs
浏览文件 @
2d74e9ba
...
...
@@ -827,7 +827,7 @@ fn lower_expr_range(
let
is_unit
=
fields
.is_empty
();
let
struct_path
=
[
sym
::
ops
,
path
];
let
struct_path
=
self
.std_path
(
span
,
&
struct_path
,
None
,
is_unit
);
let
struct_path
=
hir
::
QPath
::
Resolved
(
None
,
s
elf
.arena
.alloc
(
struct_path
)
);
let
struct_path
=
hir
::
QPath
::
Resolved
(
None
,
s
truct_path
);
if
is_unit
{
hir
::
ExprKind
::
Path
(
struct_path
)
...
...
@@ -1336,7 +1336,7 @@ fn expr_call_std_assoc_fn(
assoc_fn_name
:
&
str
,
args
:
&
'hir
[
hir
::
Expr
<
'hir
>
],
)
->
hir
::
ExprKind
<
'hir
>
{
let
ty_path
=
self
.
arena
.alloc
(
self
.std_path
(
span
,
ty_path_components
,
None
,
false
)
);
let
ty_path
=
self
.
std_path
(
span
,
ty_path_components
,
None
,
false
);
let
ty
=
self
.arena
.alloc
(
self
.ty_path
(
ty_path_id
,
span
,
hir
::
QPath
::
Resolved
(
None
,
ty_path
)));
let
fn_seg
=
self
.arena
.alloc
(
hir
::
PathSegment
::
from_ident
(
Ident
::
from_str
(
assoc_fn_name
)));
...
...
@@ -1354,11 +1354,7 @@ fn expr_std_path(
attrs
:
AttrVec
,
)
->
hir
::
Expr
<
'hir
>
{
let
path
=
self
.std_path
(
span
,
components
,
params
,
true
);
self
.expr
(
span
,
hir
::
ExprKind
::
Path
(
hir
::
QPath
::
Resolved
(
None
,
self
.arena
.alloc
(
path
))),
attrs
,
)
self
.expr
(
span
,
hir
::
ExprKind
::
Path
(
hir
::
QPath
::
Resolved
(
None
,
path
)),
attrs
)
}
pub
(
super
)
fn
expr_ident
(
...
...
src/librustc/hir/lowering/item.rs
浏览文件 @
2d74e9ba
...
...
@@ -507,7 +507,7 @@ fn lower_use_tree(
let
new_id
=
this
.lower_node_id
(
new_node_id
);
let
res
=
this
.lower_res
(
res
);
let
path
=
this
.lower_path_extra
(
res
,
&
path
,
ParamMode
::
Explicit
,
None
);
let
kind
=
hir
::
ItemKind
::
Use
(
this
.arena
.alloc
(
path
)
,
hir
::
UseKind
::
Single
);
let
kind
=
hir
::
ItemKind
::
Use
(
path
,
hir
::
UseKind
::
Single
);
let
vis
=
this
.rebuild_vis
(
&
vis
);
this
.insert_item
(
hir
::
Item
{
...
...
@@ -522,15 +522,11 @@ fn lower_use_tree(
}
let
path
=
self
.lower_path_extra
(
ret_res
,
&
path
,
ParamMode
::
Explicit
,
None
);
let
path
=
self
.arena
.alloc
(
path
);
hir
::
ItemKind
::
Use
(
path
,
hir
::
UseKind
::
Single
)
}
UseTreeKind
::
Glob
=>
{
let
path
=
self
.arena
.alloc
(
self
.lower_path
(
id
,
&
Path
{
segments
,
span
:
path
.span
},
ParamMode
::
Explicit
,
));
let
path
=
self
.lower_path
(
id
,
&
Path
{
segments
,
span
:
path
.span
},
ParamMode
::
Explicit
);
hir
::
ItemKind
::
Use
(
path
,
hir
::
UseKind
::
Glob
)
}
UseTreeKind
::
Nested
(
ref
trees
)
=>
{
...
...
@@ -618,7 +614,6 @@ fn lower_use_tree(
let
res
=
self
.expect_full_res_from_use
(
id
)
.next
()
.unwrap_or
(
Res
::
Err
);
let
res
=
self
.lower_res
(
res
);
let
path
=
self
.lower_path_extra
(
res
,
&
prefix
,
ParamMode
::
Explicit
,
None
);
let
path
=
self
.arena
.alloc
(
path
);
hir
::
ItemKind
::
Use
(
path
,
hir
::
UseKind
::
ListStem
)
}
}
...
...
@@ -627,7 +622,7 @@ fn lower_use_tree(
/// Paths like the visibility path in `pub(super) use foo::{bar, baz}` are repeated
/// many times in the HIR tree; for each occurrence, we need to assign distinct
/// `NodeId`s. (See, e.g., #56128.)
fn
rebuild_use_path
(
&
mut
self
,
path
:
&
hir
::
Path
<
'hir
>
)
->
hir
::
Path
<
'hir
>
{
fn
rebuild_use_path
(
&
mut
self
,
path
:
&
hir
::
Path
<
'hir
>
)
->
&
'hir
hir
::
Path
<
'hir
>
{
debug!
(
"rebuild_use_path(path = {:?})"
,
path
);
let
segments
=
self
.arena
.alloc_from_iter
(
path
.segments
.iter
()
.map
(|
seg
|
hir
::
PathSegment
{
...
...
@@ -637,7 +632,7 @@ fn rebuild_use_path(&mut self, path: &hir::Path<'hir>) -> hir::Path<'hir> {
args
:
None
,
infer_args
:
seg
.infer_args
,
}));
hir
::
Path
{
span
:
path
.span
,
res
:
path
.res
,
segments
}
self
.arena
.alloc
(
hir
::
Path
{
span
:
path
.span
,
res
:
path
.res
,
segments
})
}
fn
rebuild_vis
(
&
mut
self
,
vis
:
&
hir
::
Visibility
<
'hir
>
)
->
hir
::
Visibility
<
'hir
>
{
...
...
@@ -647,7 +642,7 @@ fn rebuild_vis(&mut self, vis: &hir::Visibility<'hir>) -> hir::Visibility<'hir>
hir
::
VisibilityKind
::
Inherited
=>
hir
::
VisibilityKind
::
Inherited
,
hir
::
VisibilityKind
::
Restricted
{
ref
path
,
hir_id
:
_
}
=>
{
hir
::
VisibilityKind
::
Restricted
{
path
:
self
.
arena
.alloc
(
self
.rebuild_use_path
(
path
)
),
path
:
self
.
rebuild_use_path
(
path
),
hir_id
:
self
.next_id
(),
}
}
...
...
@@ -944,12 +939,7 @@ fn lower_visibility(
let
res
=
self
.expect_full_res
(
id
);
let
res
=
self
.lower_res
(
res
);
hir
::
VisibilityKind
::
Restricted
{
path
:
self
.arena
.alloc
(
self
.lower_path_extra
(
res
,
path
,
ParamMode
::
Explicit
,
explicit_owner
,
)),
path
:
self
.lower_path_extra
(
res
,
path
,
ParamMode
::
Explicit
,
explicit_owner
),
hir_id
:
lowered_id
,
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录