Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
71f25b40
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,发现更多精彩内容 >>
未验证
提交
71f25b40
编写于
6月 28, 2018
作者:
S
Santiago Pastorino
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Run rustfmt
上级
0957ede5
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
40 addition
and
58 deletion
+40
-58
src/librustc_mir/borrow_check/nll/region_infer/mod.rs
src/librustc_mir/borrow_check/nll/region_infer/mod.rs
+20
-32
src/librustc_mir/borrow_check/nll/region_infer/values.rs
src/librustc_mir/borrow_check/nll/region_infer/values.rs
+5
-7
src/librustc_mir/borrow_check/nll/type_check/liveness.rs
src/librustc_mir/borrow_check/nll/type_check/liveness.rs
+1
-3
src/librustc_mir/borrow_check/nll/type_check/mod.rs
src/librustc_mir/borrow_check/nll/type_check/mod.rs
+14
-16
未找到文件。
src/librustc_mir/borrow_check/nll/region_infer/mod.rs
浏览文件 @
71f25b40
...
...
@@ -19,7 +19,7 @@
use
rustc
::
infer
::
RegionVariableOrigin
;
use
rustc
::
mir
::{
ClosureOutlivesRequirement
,
ClosureOutlivesSubject
,
ClosureRegionRequirements
,
Local
,
Location
,
Mir
Mir
,
};
use
rustc
::
ty
::{
self
,
RegionVid
,
Ty
,
TyCtxt
,
TypeFoldable
};
use
rustc
::
util
::
common
;
...
...
@@ -271,17 +271,11 @@ fn init_universal_regions(&mut self) {
// Add all nodes in the CFG to liveness constraints
for
point_index
in
self
.elements
.all_point_indices
()
{
self
.liveness_constraints
.add_element
(
variable
,
point_index
,
);
self
.liveness_constraints
.add_element
(
variable
,
point_index
);
}
// Add `end(X)` into the set for X.
self
.liveness_constraints
.add_element
(
variable
,
variable
,
);
self
.liveness_constraints
.add_element
(
variable
,
variable
);
}
}
...
...
@@ -335,12 +329,7 @@ pub(super) fn add_live_point(&mut self, v: RegionVid, point: Location) -> bool {
}
/// Indicates that the region variable `sup` must outlive `sub` is live at the point `point`.
pub
(
super
)
fn
add_outlives
(
&
mut
self
,
locations
:
Locations
,
sup
:
RegionVid
,
sub
:
RegionVid
,
)
{
pub
(
super
)
fn
add_outlives
(
&
mut
self
,
locations
:
Locations
,
sup
:
RegionVid
,
sub
:
RegionVid
)
{
assert
!
(
self
.inferred_values
.is_none
(),
"values already inferred"
);
self
.constraints
.push
(
OutlivesConstraint
{
locations
,
...
...
@@ -445,11 +434,14 @@ fn compute_region_values(&self, _mir: &Mir<'tcx>) -> RegionValues {
debug!
(
"propagate_constraints: sub={:?}"
,
constraint
.sub
);
debug!
(
"propagate_constraints: sup={:?}"
,
constraint
.sup
);
self
.constraints
.each_affected_by_dirty
(
dependency_map
[
constraint
.sup
],
|
dep_idx
|
{
if
clean_bit_vec
.remove
(
dep_idx
.index
())
{
dirty_list
.push
(
dep_idx
);
}
});
self
.constraints
.each_affected_by_dirty
(
dependency_map
[
constraint
.sup
],
|
dep_idx
|
{
if
clean_bit_vec
.remove
(
dep_idx
.index
())
{
dirty_list
.push
(
dep_idx
);
}
},
);
}
debug!
(
"
\n
"
);
...
...
@@ -487,8 +479,12 @@ fn check_type_tests<'gcx>(
}
if
let
Some
(
propagated_outlives_requirements
)
=
&
mut
propagated_outlives_requirements
{
if
self
.try_promote_type_test
(
infcx
,
mir
,
type_test
,
propagated_outlives_requirements
)
{
if
self
.try_promote_type_test
(
infcx
,
mir
,
type_test
,
propagated_outlives_requirements
,
)
{
continue
;
}
}
...
...
@@ -744,12 +740,7 @@ fn universal_upper_bound(&self, r: RegionVid) -> RegionVid {
/// Test if `test` is true when applied to `lower_bound` at
/// `point`, and returns true or false.
fn
eval_region_test
(
&
self
,
mir
:
&
Mir
<
'tcx
>
,
lower_bound
:
RegionVid
,
test
:
&
RegionTest
,
)
->
bool
{
fn
eval_region_test
(
&
self
,
mir
:
&
Mir
<
'tcx
>
,
lower_bound
:
RegionVid
,
test
:
&
RegionTest
)
->
bool
{
debug!
(
"eval_region_test(lower_bound={:?}, test={:?})"
,
lower_bound
,
test
...
...
@@ -781,10 +772,7 @@ fn eval_outlives(
sup_region
:
RegionVid
,
sub_region
:
RegionVid
,
)
->
bool
{
debug!
(
"eval_outlives({:?}: {:?})"
,
sup_region
,
sub_region
);
debug!
(
"eval_outlives({:?}: {:?})"
,
sup_region
,
sub_region
);
let
inferred_values
=
self
.inferred_values
...
...
src/librustc_mir/borrow_check/nll/region_infer/values.rs
浏览文件 @
71f25b40
...
...
@@ -28,7 +28,8 @@ pub(super) struct RegionValueElements {
impl
RegionValueElements
{
pub
(
super
)
fn
new
(
mir
:
&
Mir
<
'_
>
,
num_universal_regions
:
usize
)
->
Self
{
let
mut
num_points
=
0
;
let
statements_before_block
=
mir
.basic_blocks
()
let
statements_before_block
=
mir
.basic_blocks
()
.iter
()
.map
(|
block_data
|
{
let
v
=
num_points
;
...
...
@@ -96,7 +97,8 @@ pub(super) fn to_element(&self, i: RegionElementIndex) -> RegionElement {
// be (BB2, 20).
//
// Nit: we could do a binary search here but I'm too lazy.
let
(
block
,
&
first_index
)
=
self
.statements_before_block
let
(
block
,
&
first_index
)
=
self
.statements_before_block
.iter_enumerated
()
.filter
(|(
_
,
first_index
)|
**
first_index
<=
point_index
)
.last
()
...
...
@@ -203,11 +205,7 @@ pub(super) fn new(elements: &Rc<RegionValueElements>, num_region_variables: usiz
/// Adds the given element to the value for the given region. Returns true if
/// the element is newly added (i.e., was not already present).
pub
(
super
)
fn
add_element
<
E
:
ToElementIndex
>
(
&
mut
self
,
r
:
RegionVid
,
elem
:
E
,
)
->
bool
{
pub
(
super
)
fn
add_element
<
E
:
ToElementIndex
>
(
&
mut
self
,
r
:
RegionVid
,
elem
:
E
)
->
bool
{
let
i
=
self
.elements
.index
(
elem
);
debug!
(
"add(r={:?}, elem={:?})"
,
r
,
elem
);
self
.matrix
.add
(
r
,
i
)
...
...
src/librustc_mir/borrow_check/nll/type_check/liveness.rs
浏览文件 @
71f25b40
...
...
@@ -168,9 +168,7 @@ fn push_type_live_constraint<T>(
);
cx
.tcx
()
.for_each_free_region
(
&
value
,
|
live_region
|
{
cx
.constraints
.liveness_set
.push
((
live_region
,
location
));
cx
.constraints.liveness_set
.push
((
live_region
,
location
));
});
}
...
...
src/librustc_mir/borrow_check/nll/type_check/mod.rs
浏览文件 @
71f25b40
...
...
@@ -311,7 +311,10 @@ fn sanitize_constant(&mut self, constant: &Constant<'tcx>, location: Location) {
debug!
(
"sanitize_constant: expected_ty={:?}"
,
expected_ty
);
if
let
Err
(
terr
)
=
self
.cx
.eq_types
(
expected_ty
,
constant
.ty
,
location
.boring
())
{
if
let
Err
(
terr
)
=
self
.cx
.eq_types
(
expected_ty
,
constant
.ty
,
location
.boring
())
{
span_mirbug!
(
self
,
constant
,
...
...
@@ -770,12 +773,7 @@ fn push_region_constraints(
}
}
fn
sub_types
(
&
mut
self
,
sub
:
Ty
<
'tcx
>
,
sup
:
Ty
<
'tcx
>
,
locations
:
Locations
,
)
->
Fallible
<
()
>
{
fn
sub_types
(
&
mut
self
,
sub
:
Ty
<
'tcx
>
,
sup
:
Ty
<
'tcx
>
,
locations
:
Locations
)
->
Fallible
<
()
>
{
let
param_env
=
self
.param_env
;
self
.fully_perform_op
(
locations
,
...
...
@@ -807,7 +805,11 @@ fn check_stmt(&mut self, mir: &Mir<'tcx>, stmt: &Statement<'tcx>, location: Loca
false
};
let
locations
=
if
is_temp
{
location
.boring
()
}
else
{
location
.interesting
()
};
let
locations
=
if
is_temp
{
location
.boring
()
}
else
{
location
.interesting
()
};
let
place_ty
=
place
.ty
(
mir
,
tcx
)
.to_ty
(
tcx
);
let
rv_ty
=
rv
.ty
(
mir
,
tcx
);
...
...
@@ -982,10 +984,9 @@ fn check_terminator(
// output) types in the signature must be live, since
// all the inputs that fed into it were live.
for
&
late_bound_region
in
map
.values
()
{
self
.constraints.liveness_set
.push
((
late_bound_region
,
term_location
,
));
self
.constraints
.liveness_set
.push
((
late_bound_region
,
term_location
));
}
self
.check_call_inputs
(
mir
,
term
,
&
sig
,
args
,
term_location
);
...
...
@@ -1505,10 +1506,7 @@ fn prove_aggregate_predicates(
);
// Hmm, are these constraints *really* boring?
self
.push_region_constraints
(
location
.boring
(),
&
closure_constraints
,
);
self
.push_region_constraints
(
location
.boring
(),
&
closure_constraints
);
}
tcx
.predicates_of
(
*
def_id
)
.instantiate
(
tcx
,
substs
.substs
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录