Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
48349960
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,发现更多精彩内容 >>
未验证
提交
48349960
编写于
10月 08, 2019
作者:
S
Santiago Pastorino
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use Cow to handle modifications of projection in preparation for interning
上级
d53fc9ca
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
67 addition
and
49 deletion
+67
-49
src/librustc/mir/visit.rs
src/librustc/mir/visit.rs
+22
-11
src/librustc_mir/borrow_check/nll/renumber.rs
src/librustc_mir/borrow_check/nll/renumber.rs
+8
-4
src/librustc_mir/transform/erase_regions.rs
src/librustc_mir/transform/erase_regions.rs
+8
-4
src/librustc_mir/transform/generator.rs
src/librustc_mir/transform/generator.rs
+9
-15
src/librustc_mir/transform/inline.rs
src/librustc_mir/transform/inline.rs
+8
-4
src/librustc_mir/transform/promote_consts.rs
src/librustc_mir/transform/promote_consts.rs
+3
-3
src/librustc_mir/transform/simplify.rs
src/librustc_mir/transform/simplify.rs
+6
-5
src/librustc_mir/util/def_use.rs
src/librustc_mir/util/def_use.rs
+3
-3
未找到文件。
src/librustc/mir/visit.rs
浏览文件 @
48349960
...
...
@@ -792,26 +792,37 @@ fn super_place(
)
{
self
.visit_place_base
(
&
mut
place
.base
,
context
,
location
);
place
.projection
=
self
.process_projection
(
&
place
.projection
);
if
let
Some
(
new_projection
)
=
self
.process_projection
(
&
place
.projection
)
{
place
.projection
=
new_projection
;
}
}
fn
process_projection
(
&
mut
self
,
projection
:
&
Box
<
[
PlaceElem
<
'tcx
>
]
>
,
)
->
Box
<
[
PlaceElem
<
'tcx
>
]
>
{
let
new_projection
:
Vec
<
_
>
=
projection
.iter
()
.map
(|
elem
|
self
.process_projection_elem
(
elem
)
)
.collect
();
projection
:
&
'a
[
PlaceElem
<
'tcx
>
],
)
->
Option
<
Box
<
[
PlaceElem
<
'tcx
>
]
>>
{
let
mut
projection
=
Cow
::
Borrowed
(
projection
);
for
i
in
0
..
projection
.len
()
{
if
let
Some
(
elem
)
=
projection
.get
(
i
)
{
if
let
Some
(
elem
)
=
self
.process_projection_elem
(
elem
)
{
let
vec
=
projection
.to_mut
();
vec
[
i
]
=
elem
;
}
}
}
new_projection
.into_boxed_slice
()
match
projection
{
Cow
::
Borrowed
(
_
)
=>
None
,
Cow
::
Owned
(
vec
)
=>
Some
(
vec
.into_boxed_slice
()),
}
}
fn
process_projection_elem
(
&
mut
self
,
elem
:
&
PlaceElem
<
'tcx
>
,
)
->
PlaceElem
<
'tcx
>
{
// FIXME: avoid cloning here
elem
.clone
()
_
elem
:
&
PlaceElem
<
'tcx
>
,
)
->
Option
<
PlaceElem
<
'tcx
>>
{
None
}
);
...
...
src/librustc_mir/borrow_check/nll/renumber.rs
浏览文件 @
48349960
...
...
@@ -65,12 +65,16 @@ fn visit_ty(&mut self, ty: &mut Ty<'tcx>, ty_context: TyContext) {
fn
process_projection_elem
(
&
mut
self
,
elem
:
&
PlaceElem
<
'tcx
>
,
)
->
PlaceElem
<
'tcx
>
{
)
->
Option
<
PlaceElem
<
'tcx
>
>
{
if
let
PlaceElem
::
Field
(
field
,
ty
)
=
elem
{
PlaceElem
::
Field
(
*
field
,
self
.renumber_regions
(
ty
))
}
else
{
elem
.clone
()
let
new_ty
=
self
.renumber_regions
(
ty
);
if
new_ty
!=
*
ty
{
return
Some
(
PlaceElem
::
Field
(
*
field
,
new_ty
));
}
}
None
}
fn
visit_substs
(
&
mut
self
,
substs
:
&
mut
SubstsRef
<
'tcx
>
,
location
:
Location
)
{
...
...
src/librustc_mir/transform/erase_regions.rs
浏览文件 @
48349960
...
...
@@ -42,12 +42,16 @@ fn visit_substs(&mut self, substs: &mut SubstsRef<'tcx>, _: Location) {
fn
process_projection_elem
(
&
mut
self
,
elem
:
&
PlaceElem
<
'tcx
>
,
)
->
PlaceElem
<
'tcx
>
{
)
->
Option
<
PlaceElem
<
'tcx
>
>
{
if
let
PlaceElem
::
Field
(
field
,
ty
)
=
elem
{
PlaceElem
::
Field
(
*
field
,
self
.tcx
.erase_regions
(
ty
))
}
else
{
elem
.clone
()
let
new_ty
=
self
.tcx
.erase_regions
(
ty
);
if
new_ty
!=
*
ty
{
return
Some
(
PlaceElem
::
Field
(
*
field
,
new_ty
));
}
}
None
}
}
...
...
src/librustc_mir/transform/generator.rs
浏览文件 @
48349960
...
...
@@ -89,22 +89,16 @@ fn visit_local(&mut self,
}
}
fn
visit_place
(
&
mut
self
,
place
:
&
mut
Place
<
'tcx
>
,
context
:
PlaceContext
,
location
:
Location
)
{
self
.visit_place_base
(
&
mut
place
.base
,
context
,
location
);
let
new_projection
:
Vec
<
_
>
=
place
.projection
.iter
()
.map
(|
elem
|
match
elem
{
PlaceElem
::
Index
(
local
)
if
*
local
==
self
.from
=>
{
PlaceElem
::
Index
(
self
.to
)
}
_
=>
elem
.clone
(),
fn
process_projection_elem
(
&
mut
self
,
elem
:
&
PlaceElem
<
'tcx
>
,
)
->
Option
<
PlaceElem
<
'tcx
>>
{
match
elem
{
PlaceElem
::
Index
(
local
)
if
*
local
==
self
.from
=>
{
Some
(
PlaceElem
::
Index
(
self
.to
))
}
)
.collect
();
place
.projection
=
new_projection
.into_boxed_slice
();
_
=>
None
,
}
}
}
...
...
src/librustc_mir/transform/inline.rs
浏览文件 @
48349960
...
...
@@ -703,12 +703,16 @@ fn visit_place(
fn
process_projection_elem
(
&
mut
self
,
elem
:
&
PlaceElem
<
'tcx
>
,
)
->
PlaceElem
<
'tcx
>
{
)
->
Option
<
PlaceElem
<
'tcx
>
>
{
if
let
PlaceElem
::
Index
(
local
)
=
elem
{
PlaceElem
::
Index
(
self
.make_integrate_local
(
local
))
}
else
{
elem
.clone
()
let
new_local
=
self
.make_integrate_local
(
local
);
if
new_local
!=
*
local
{
return
Some
(
PlaceElem
::
Index
(
new_local
))
}
}
None
}
fn
visit_basic_block_data
(
&
mut
self
,
block
:
BasicBlock
,
data
:
&
mut
BasicBlockData
<
'tcx
>
)
{
...
...
src/librustc_mir/transform/promote_consts.rs
浏览文件 @
48349960
...
...
@@ -408,12 +408,12 @@ fn visit_local(&mut self,
fn
process_projection_elem
(
&
mut
self
,
elem
:
&
PlaceElem
<
'tcx
>
,
)
->
PlaceElem
<
'tcx
>
{
)
->
Option
<
PlaceElem
<
'tcx
>
>
{
match
elem
{
PlaceElem
::
Index
(
local
)
if
self
.is_temp_kind
(
*
local
)
=>
{
PlaceElem
::
Index
(
self
.promote_temp
(
*
local
))
Some
(
PlaceElem
::
Index
(
self
.promote_temp
(
*
local
)
))
}
_
=>
elem
.clone
()
,
_
=>
None
,
}
}
}
...
...
src/librustc_mir/transform/simplify.rs
浏览文件 @
48349960
...
...
@@ -374,11 +374,12 @@ fn visit_local(&mut self, l: &mut Local, _: PlaceContext, _: Location) {
fn
process_projection_elem
(
&
mut
self
,
elem
:
&
PlaceElem
<
'tcx
>
,
)
->
PlaceElem
<
'tcx
>
{
if
let
PlaceElem
::
Index
(
local
)
=
elem
{
PlaceElem
::
Index
(
self
.map
[
*
local
]
.unwrap
())
}
else
{
elem
.clone
()
)
->
Option
<
PlaceElem
<
'tcx
>>
{
match
elem
{
PlaceElem
::
Index
(
local
)
=>
{
Some
(
PlaceElem
::
Index
(
self
.map
[
*
local
]
.unwrap
()))
}
_
=>
None
}
}
}
src/librustc_mir/util/def_use.rs
浏览文件 @
48349960
...
...
@@ -141,12 +141,12 @@ fn visit_local(&mut self,
fn
process_projection_elem
(
&
mut
self
,
elem
:
&
PlaceElem
<
'tcx
>
,
)
->
PlaceElem
<
'tcx
>
{
)
->
Option
<
PlaceElem
<
'tcx
>
>
{
match
elem
{
PlaceElem
::
Index
(
local
)
if
*
local
==
self
.query
=>
{
PlaceElem
::
Index
(
self
.new_local
)
Some
(
PlaceElem
::
Index
(
self
.new_local
)
)
}
_
=>
elem
.clone
()
,
_
=>
None
,
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录