Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
a13e4aea
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,发现更多精彩内容 >>
提交
a13e4aea
编写于
8月 10, 2018
作者:
N
Niko Matsakis
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove the liveness mode and simplify `categorize`
Less modes!
上级
8785e348
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
17 addition
and
43 deletion
+17
-43
src/librustc_mir/borrow_check/nll/explain_borrow/find_use.rs
src/librustc_mir/borrow_check/nll/explain_borrow/find_use.rs
+7
-25
src/librustc_mir/util/liveness.rs
src/librustc_mir/util/liveness.rs
+10
-18
未找到文件。
src/librustc_mir/borrow_check/nll/explain_borrow/find_use.rs
浏览文件 @
a13e4aea
...
...
@@ -17,7 +17,7 @@
use
rustc
::
mir
::{
Local
,
Location
,
Mir
};
use
rustc
::
ty
::{
RegionVid
,
TyCtxt
};
use
rustc_data_structures
::
fx
::
FxHashSet
;
use
util
::
liveness
::{
self
,
DefUse
,
LivenessMode
};
use
util
::
liveness
::{
self
,
DefUse
};
crate
fn
find
<
'tcx
>
(
mir
:
&
Mir
<
'tcx
>
,
...
...
@@ -32,10 +32,6 @@
tcx
,
region_vid
,
start_point
,
liveness_mode
:
LivenessMode
{
include_regular_use
:
true
,
include_drops
:
true
,
},
};
uf
.find
()
...
...
@@ -47,7 +43,6 @@ struct UseFinder<'cx, 'gcx: 'tcx, 'tcx: 'cx> {
tcx
:
TyCtxt
<
'cx
,
'gcx
,
'tcx
>
,
region_vid
:
RegionVid
,
start_point
:
Location
,
liveness_mode
:
LivenessMode
,
}
impl
<
'cx
,
'gcx
,
'tcx
>
UseFinder
<
'cx
,
'gcx
,
'tcx
>
{
...
...
@@ -108,7 +103,6 @@ fn def_use(&self, location: Location, thing: &dyn MirVisitable<'tcx>) -> Option<
mir
:
self
.mir
,
tcx
:
self
.tcx
,
region_vid
:
self
.region_vid
,
liveness_mode
:
self
.liveness_mode
,
def_use_result
:
None
,
};
...
...
@@ -122,7 +116,6 @@ struct DefUseVisitor<'cx, 'gcx: 'tcx, 'tcx: 'cx> {
mir
:
&
'cx
Mir
<
'tcx
>
,
tcx
:
TyCtxt
<
'cx
,
'gcx
,
'tcx
>
,
region_vid
:
RegionVid
,
liveness_mode
:
LivenessMode
,
def_use_result
:
Option
<
DefUseResult
>
,
}
...
...
@@ -146,23 +139,12 @@ fn visit_local(&mut self, &local: &Local, context: PlaceContext<'tcx>, _: Locati
});
if
found_it
{
match
liveness
::
categorize
(
context
,
self
.liveness_mode
)
{
Some
(
DefUse
::
Def
)
=>
{
self
.def_use_result
=
Some
(
DefUseResult
::
Def
);
}
Some
(
DefUse
::
Use
)
=>
{
self
.def_use_result
=
if
context
.is_drop
()
{
Some
(
DefUseResult
::
UseDrop
{
local
})
}
else
{
Some
(
DefUseResult
::
UseLive
{
local
})
};
}
None
=>
{
self
.def_use_result
=
None
;
}
}
self
.def_use_result
=
match
liveness
::
categorize
(
context
)
{
Some
(
DefUse
::
Def
)
=>
Some
(
DefUseResult
::
Def
),
Some
(
DefUse
::
Use
)
=>
Some
(
DefUseResult
::
UseLive
{
local
}),
Some
(
DefUse
::
Drop
)
=>
Some
(
DefUseResult
::
UseDrop
{
local
}),
None
=>
None
,
};
}
}
}
src/librustc_mir/util/liveness.rs
浏览文件 @
a13e4aea
...
...
@@ -279,9 +279,10 @@ pub fn simulate_block<'tcx, OP>(
pub
enum
DefUse
{
Def
,
Use
,
Drop
,
}
pub
fn
categorize
<
'tcx
>
(
context
:
PlaceContext
<
'tcx
>
,
mode
:
LivenessMode
)
->
Option
<
DefUse
>
{
pub
fn
categorize
<
'tcx
>
(
context
:
PlaceContext
<
'tcx
>
)
->
Option
<
DefUse
>
{
match
context
{
///////////////////////////////////////////////////////////////////////////
// DEFS
...
...
@@ -322,13 +323,8 @@ pub fn categorize<'tcx>(context: PlaceContext<'tcx>, mode: LivenessMode) -> Opti
PlaceContext
::
Inspect
|
PlaceContext
::
Copy
|
PlaceContext
::
Move
|
PlaceContext
::
Validate
=>
{
if
mode
.include_regular_use
{
Some
(
DefUse
::
Use
)
}
else
{
None
}
}
PlaceContext
::
Validate
=>
Some
(
DefUse
::
Use
),
///////////////////////////////////////////////////////////////////////////
// DROP USES
...
...
@@ -338,13 +334,8 @@ pub fn categorize<'tcx>(context: PlaceContext<'tcx>, mode: LivenessMode) -> Opti
// uses in drop are special because `#[may_dangle]`
// attributes can affect whether lifetimes must be live.
PlaceContext
::
Drop
=>
{
if
mode
.include_drops
{
Some
(
DefUse
::
Use
)
}
else
{
None
}
}
PlaceContext
::
Drop
=>
Some
(
DefUse
::
Drop
),
}
}
...
...
@@ -434,10 +425,11 @@ impl<'tcx, 'lv, V, M> Visitor<'tcx> for DefsUsesVisitor<'lv, V, M>
{
fn
visit_local
(
&
mut
self
,
&
local
:
&
Local
,
context
:
PlaceContext
<
'tcx
>
,
_
:
Location
)
{
if
let
Some
(
v_index
)
=
self
.map
.from_local
(
local
)
{
match
categorize
(
context
,
self
.mode
)
{
match
categorize
(
context
)
{
Some
(
DefUse
::
Def
)
=>
self
.defs_uses
.add_def
(
v_index
),
Some
(
DefUse
::
Use
)
=>
self
.defs_uses
.add_use
(
v_index
),
None
=>
(),
Some
(
DefUse
::
Use
)
if
self
.mode.include_regular_use
=>
self
.defs_uses
.add_use
(
v_index
),
Some
(
DefUse
::
Drop
)
if
self
.mode.include_drops
=>
self
.defs_uses
.add_use
(
v_index
),
_
=>
(),
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录