Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
497a3b4f
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,发现更多精彩内容 >>
提交
497a3b4f
编写于
6月 27, 2018
作者:
E
Eh2406
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix typo and tidy
上级
e2c0378a
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
31 addition
and
16 deletion
+31
-16
src/librustc_mir/borrow_check/nll/constraint_set.rs
src/librustc_mir/borrow_check/nll/constraint_set.rs
+19
-4
src/librustc_mir/borrow_check/nll/region_infer/dump_mir.rs
src/librustc_mir/borrow_check/nll/region_infer/dump_mir.rs
+1
-1
src/librustc_mir/borrow_check/nll/region_infer/graphviz.rs
src/librustc_mir/borrow_check/nll/region_infer/graphviz.rs
+1
-1
src/librustc_mir/borrow_check/nll/region_infer/mod.rs
src/librustc_mir/borrow_check/nll/region_infer/mod.rs
+10
-10
未找到文件。
src/librustc_mir/borrow_check/nll/constraint_set.rs
浏览文件 @
497a3b4f
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use
rustc_data_structures
::
indexed_vec
::{
Idx
,
IndexVec
};
use
rustc_data_structures
::
fx
::
FxHashSet
;
use
rustc
::
ty
::
RegionVid
;
...
...
@@ -14,7 +24,10 @@
impl
ConstraintSet
{
pub
fn
push
(
&
mut
self
,
outlives_constraint
:
OutlivesConstraint
)
{
debug!
(
"add_outlives({:?}: {:?} @ {:?}"
,
outlives_constraint
.sup
,
outlives_constraint
.sub
,
outlives_constraint
.point
);
debug!
(
"add_outlives({:?}: {:?} @ {:?}"
,
outlives_constraint
.sup
,
outlives_constraint
.sub
,
outlives_constraint
.point
);
if
outlives_constraint
.sup
==
outlives_constraint
.sub
{
// 'a: 'a is pretty uninteresting
return
;
...
...
@@ -24,12 +37,14 @@ pub fn push(&mut self, outlives_constraint: OutlivesConstraint) {
}
}
pub
fn
iner
(
&
self
)
->
&
IndexVec
<
ConstraintIndex
,
OutlivesConstraint
>
{
pub
fn
in
n
er
(
&
self
)
->
&
IndexVec
<
ConstraintIndex
,
OutlivesConstraint
>
{
&
self
.constraints
}
/// Do Not use this to add nor remove items to the Vec, nor change the `sup`, nor `sub` of the data.
pub
fn
iner_mut
(
&
mut
self
)
->
&
mut
IndexVec
<
ConstraintIndex
,
OutlivesConstraint
>
{
/// Do Not use this to add nor remove items to the Vec,
/// nor change the `sup`,
/// nor `sub` of the data.
pub
fn
inner_mut
(
&
mut
self
)
->
&
mut
IndexVec
<
ConstraintIndex
,
OutlivesConstraint
>
{
&
mut
self
.constraints
}
}
...
...
src/librustc_mir/borrow_check/nll/region_infer/dump_mir.rs
浏览文件 @
497a3b4f
...
...
@@ -76,7 +76,7 @@ fn for_each_constraint(
}
}
let
mut
constraints
:
Vec
<
_
>
=
self
.constraints
.iner
()
.iter
()
.collect
();
let
mut
constraints
:
Vec
<
_
>
=
self
.constraints
.in
n
er
()
.iter
()
.collect
();
constraints
.sort
();
for
constraint
in
&
constraints
{
let
OutlivesConstraint
{
...
...
src/librustc_mir/borrow_check/nll/region_infer/graphviz.rs
浏览文件 @
497a3b4f
...
...
@@ -57,7 +57,7 @@ fn nodes(&'this self) -> dot::Nodes<'this, RegionVid> {
vids
.into_cow
()
}
fn
edges
(
&
'this
self
)
->
dot
::
Edges
<
'this
,
OutlivesConstraint
>
{
(
&
self
.constraints
.iner
()
.raw
[
..
])
.into_cow
()
(
&
self
.constraints
.in
n
er
()
.raw
[
..
])
.into_cow
()
}
// Render `a: b` as `a <- b`, indicating the flow
...
...
src/librustc_mir/borrow_check/nll/region_infer/mod.rs
浏览文件 @
497a3b4f
...
...
@@ -216,7 +216,7 @@ pub(crate) fn new(
type_tests
:
Vec
<
TypeTest
<
'tcx
>>
,
)
->
Self
{
// The `next` field should not yet have been initialized:
debug_assert!
(
outlives_constraints
.iner
()
.iter
()
.all
(|
c
|
c
.next
.is_none
()));
debug_assert!
(
outlives_constraints
.in
n
er
()
.iter
()
.all
(|
c
|
c
.next
.is_none
()));
let
num_region_variables
=
var_infos
.len
();
let
num_universal_regions
=
universal_regions
.len
();
...
...
@@ -438,7 +438,7 @@ fn propagate_constraints(&mut self, mir: &Mir<'tcx>) {
fn
compute_region_values
(
&
self
,
_
mir
:
&
Mir
<
'tcx
>
)
->
RegionValues
{
debug!
(
"compute_region_values()"
);
debug!
(
"compute_region_values: constraints={:#?}"
,
{
let
mut
constraints
:
Vec
<
_
>
=
self
.constraints
.iner
()
.iter
()
.collect
();
let
mut
constraints
:
Vec
<
_
>
=
self
.constraints
.in
n
er
()
.iter
()
.collect
();
constraints
.sort
();
constraints
});
...
...
@@ -450,7 +450,7 @@ fn compute_region_values(&self, _mir: &Mir<'tcx>) -> RegionValues {
let
dependency_map
=
self
.dependency_map
.as_ref
()
.unwrap
();
// Constraints that may need to be repropagated (initially all):
let
mut
dirty_list
:
Vec
<
_
>
=
self
.constraints
.iner
()
.indices
()
.collect
();
let
mut
dirty_list
:
Vec
<
_
>
=
self
.constraints
.in
n
er
()
.indices
()
.collect
();
// Set to 0 for each constraint that is on the dirty list:
let
mut
clean_bit_vec
=
BitVector
::
new
(
dirty_list
.len
());
...
...
@@ -459,7 +459,7 @@ fn compute_region_values(&self, _mir: &Mir<'tcx>) -> RegionValues {
while
let
Some
(
constraint_idx
)
=
dirty_list
.pop
()
{
clean_bit_vec
.insert
(
constraint_idx
.index
());
let
constraint
=
&
self
.constraints
.iner
()[
constraint_idx
];
let
constraint
=
&
self
.constraints
.in
n
er
()[
constraint_idx
];
debug!
(
"propagate_constraints: constraint={:?}"
,
constraint
);
if
inferred_values
.add_region
(
constraint
.sup
,
constraint
.sub
)
{
...
...
@@ -471,7 +471,7 @@ fn compute_region_values(&self, _mir: &Mir<'tcx>) -> RegionValues {
if
clean_bit_vec
.remove
(
dep_idx
.index
())
{
dirty_list
.push
(
dep_idx
);
}
opt_dep_idx
=
self
.constraints
.iner
()[
dep_idx
]
.next
;
opt_dep_idx
=
self
.constraints
.in
n
er
()[
dep_idx
]
.next
;
}
}
...
...
@@ -488,7 +488,7 @@ fn compute_region_values(&self, _mir: &Mir<'tcx>) -> RegionValues {
fn
build_dependency_map
(
&
mut
self
)
->
IndexVec
<
RegionVid
,
Option
<
ConstraintIndex
>>
{
let
mut
map
=
IndexVec
::
from_elem
(
None
,
&
self
.definitions
);
for
(
idx
,
constraint
)
in
self
.constraints
.iner_mut
()
.iter_enumerated_mut
()
.rev
()
{
for
(
idx
,
constraint
)
in
self
.constraints
.in
n
er_mut
()
.iter_enumerated_mut
()
.rev
()
{
let
mut
head
=
&
mut
map
[
constraint
.sub
];
debug_assert!
(
constraint
.next
.is_none
());
constraint
.next
=
*
head
;
...
...
@@ -936,7 +936,7 @@ fn check_universal_region<'gcx>(
);
let
blame_index
=
self
.blame_constraint
(
longer_fr
,
shorter_fr
);
let
blame_span
=
self
.constraints
.iner
()[
blame_index
]
.span
;
let
blame_span
=
self
.constraints
.in
n
er
()[
blame_index
]
.span
;
if
let
Some
(
propagated_outlives_requirements
)
=
propagated_outlives_requirements
{
// Shrink `fr` until we find a non-local region (if we do).
...
...
@@ -1027,7 +1027,7 @@ fn report_error(
// - `fr1: X` transitively
// - and `Y` is live at `elem`
let
index
=
self
.blame_constraint
(
fr1
,
elem
);
let
region_sub
=
self
.constraints
.iner
()[
index
]
.sub
;
let
region_sub
=
self
.constraints
.in
n
er
()[
index
]
.sub
;
// then return why `Y` was live at `elem`
self
.liveness_constraints
.cause
(
region_sub
,
elem
)
...
...
@@ -1048,7 +1048,7 @@ fn blame_constraint(&self, fr1: RegionVid, elem: impl ToElementIndex) -> Constra
// of dependencies, which doesn't account for the locations of
// contraints at all. But it will do for now.
let
relevant_constraint
=
self
.constraints
.iner
()
.in
n
er
()
.iter_enumerated
()
.filter_map
(|(
i
,
constraint
)|
{
if
!
self
.liveness_constraints
.contains
(
constraint
.sub
,
elem
)
{
...
...
@@ -1084,7 +1084,7 @@ fn dependencies(&self, r0: RegionVid) -> IndexVec<RegionVid, Option<usize>> {
while
changed
{
changed
=
false
;
for
constraint
in
self
.constraints
.iner
()
{
for
constraint
in
self
.constraints
.in
n
er
()
{
if
let
Some
(
n
)
=
result_set
[
constraint
.sup
]
{
let
m
=
n
+
1
;
if
result_set
[
constraint
.sub
]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录