Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
15739b82
R
Rust
项目概览
int
/
Rust
12 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
15739b82
编写于
11月 14, 2017
作者:
N
Niko Matsakis
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Nit: rework region obligations to a snapshotted vector
上级
f7225910
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
31 addition
and
18 deletion
+31
-18
src/librustc/infer/mod.rs
src/librustc/infer/mod.rs
+10
-3
src/librustc/infer/outlives/obligations.rs
src/librustc/infer/outlives/obligations.rs
+19
-13
src/librustc/lib.rs
src/librustc/lib.rs
+1
-0
src/librustc/traits/mod.rs
src/librustc/traits/mod.rs
+1
-2
未找到文件。
src/librustc/infer/mod.rs
浏览文件 @
15739b82
...
...
@@ -35,7 +35,7 @@
use
syntax
::
ast
;
use
errors
::
DiagnosticBuilder
;
use
syntax_pos
::{
self
,
Span
,
DUMMY_SP
};
use
util
::
nodemap
::
{
NodeMap
,
FxHashMap
}
;
use
util
::
nodemap
::
FxHashMap
;
use
arena
::
DroplessArena
;
use
self
::
combine
::
CombineFields
;
...
...
@@ -179,7 +179,7 @@ pub struct InferCtxt<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
// for each body-id in this map, which will process the
// obligations within. This is expected to be done 'late enough'
// that all type inference variables have been bound and so forth.
region_obligations
:
RefCell
<
NodeMap
<
Vec
<
RegionObligation
<
'tcx
>>
>>
,
region_obligations
:
RefCell
<
Vec
<
(
ast
::
NodeId
,
RegionObligation
<
'tcx
>
)
>>
,
}
/// A map returned by `skolemize_late_bound_regions()` indicating the skolemized
...
...
@@ -450,7 +450,7 @@ pub fn enter<F, R>(&'tcx mut self, f: F) -> R
tainted_by_errors_flag
:
Cell
::
new
(
false
),
err_count_on_creation
:
tcx
.sess
.err_count
(),
in_snapshot
:
Cell
::
new
(
false
),
region_obligations
:
RefCell
::
new
(
NodeMap
()
),
region_obligations
:
RefCell
::
new
(
vec!
[]
),
}))
}
}
...
...
@@ -478,6 +478,7 @@ pub struct CombinedSnapshot<'a, 'tcx:'a> {
int_snapshot
:
unify
::
Snapshot
<
ty
::
IntVid
>
,
float_snapshot
:
unify
::
Snapshot
<
ty
::
FloatVid
>
,
region_constraints_snapshot
:
RegionSnapshot
,
region_obligations_snapshot
:
usize
,
was_in_snapshot
:
bool
,
_
in_progress_tables
:
Option
<
Ref
<
'a
,
ty
::
TypeckTables
<
'tcx
>>>
,
}
...
...
@@ -786,6 +787,7 @@ fn start_snapshot<'b>(&'b self) -> CombinedSnapshot<'b, 'tcx> {
int_snapshot
:
self
.int_unification_table
.borrow_mut
()
.snapshot
(),
float_snapshot
:
self
.float_unification_table
.borrow_mut
()
.snapshot
(),
region_constraints_snapshot
:
self
.borrow_region_constraints
()
.start_snapshot
(),
region_obligations_snapshot
:
self
.region_obligations
.borrow
()
.len
(),
was_in_snapshot
:
in_snapshot
,
// Borrow tables "in progress" (i.e. during typeck)
// to ban writes from within a snapshot to them.
...
...
@@ -802,6 +804,7 @@ fn rollback_to(&self, cause: &str, snapshot: CombinedSnapshot) {
int_snapshot
,
float_snapshot
,
region_constraints_snapshot
,
region_obligations_snapshot
,
was_in_snapshot
,
_
in_progress_tables
}
=
snapshot
;
...
...
@@ -819,6 +822,9 @@ fn rollback_to(&self, cause: &str, snapshot: CombinedSnapshot) {
self
.float_unification_table
.borrow_mut
()
.rollback_to
(
float_snapshot
);
self
.region_obligations
.borrow_mut
()
.truncate
(
region_obligations_snapshot
);
self
.borrow_region_constraints
()
.rollback_to
(
region_constraints_snapshot
);
}
...
...
@@ -830,6 +836,7 @@ fn commit_from(&self, snapshot: CombinedSnapshot) {
int_snapshot
,
float_snapshot
,
region_constraints_snapshot
,
region_obligations_snapshot
:
_
,
was_in_snapshot
,
_
in_progress_tables
}
=
snapshot
;
...
...
src/librustc/infer/outlives/obligations.rs
浏览文件 @
15739b82
...
...
@@ -86,9 +86,7 @@ pub fn register_region_obligation(
)
{
self
.region_obligations
.borrow_mut
()
.entry
(
body_id
)
.or_insert
(
vec!
[])
.push
(
obligation
);
.push
((
body_id
,
obligation
));
}
/// Process the region obligations that must be proven (during
...
...
@@ -131,10 +129,16 @@ pub fn process_registered_region_obligations(
param_env
:
ty
::
ParamEnv
<
'tcx
>
,
body_id
:
ast
::
NodeId
,
)
{
let
region_obligations
=
match
self
.region_obligations
.borrow_mut
()
.remove
(
&
body_id
)
{
None
=>
vec!
[],
Some
(
vec
)
=>
vec
,
};
assert
!
(
!
self
.in_snapshot
.get
(),
"cannot process registered region obligations in a snapshot"
);
// pull out the region obligations with the given `body_id` (leaving the rest)
let
mut
my_region_obligations
=
Vec
::
with_capacity
(
self
.region_obligations
.borrow
()
.len
());
{
let
mut
r_o
=
self
.region_obligations
.borrow_mut
();
for
(
_
,
obligation
)
in
r_o
.drain_filter
(|(
ro_body_id
,
_
)|
*
ro_body_id
==
body_id
)
{
my_region_obligations
.push
(
obligation
);
}
}
let
outlives
=
TypeOutlives
::
new
(
self
,
region_bound_pairs
,
implicit_region_bound
,
param_env
);
...
...
@@ -143,7 +147,7 @@ pub fn process_registered_region_obligations(
sup_type
,
sub_region
,
cause
,
}
in
region_obligations
}
in
my_
region_obligations
{
let
origin
=
SubregionOrigin
::
from_obligation_cause
(
&
cause
,
...
...
@@ -170,11 +174,13 @@ pub fn type_must_outlive(
outlives
.type_must_outlive
(
origin
,
ty
,
region
);
}
/// Ignore the region obligations for a given `body_id`, not bothering to
/// prove them. This function should not really exist; it is used to accommodate some older
/// code for the time being.
pub
fn
ignore_region_obligations
(
&
self
,
body_id
:
ast
::
NodeId
)
{
self
.region_obligations
.borrow_mut
()
.remove
(
&
body_id
);
/// Ignore the region obligations, not bothering to prove
/// them. This function should not really exist; it is used to
/// accommodate some older code for the time being.
pub
fn
ignore_region_obligations
(
&
self
)
{
assert
!
(
!
self
.in_snapshot
.get
(),
"cannot ignore registered region obligations in a snapshot"
);
self
.region_obligations
.borrow_mut
()
.clear
();
}
}
...
...
src/librustc/lib.rs
浏览文件 @
15739b82
...
...
@@ -45,6 +45,7 @@
#![feature(conservative_impl_trait)]
#![feature(const_fn)]
#![feature(core_intrinsics)]
#![feature(drain_filter)]
#![feature(i128_type)]
#![feature(match_default_bindings)]
#![feature(inclusive_range_syntax)]
...
...
src/librustc/traits/mod.rs
浏览文件 @
15739b82
...
...
@@ -511,7 +511,6 @@ pub fn normalize_param_env_or_error<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
unnormalized_env
.reveal
);
tcx
.infer_ctxt
()
.enter
(|
infcx
|
{
let
body_id
=
cause
.body_id
;
let
predicates
=
match
fully_normalize
(
&
infcx
,
cause
,
...
...
@@ -546,7 +545,7 @@ pub fn normalize_param_env_or_error<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
// properly, and that code is currently largely confined to
// regionck (though I made some efforts to extract it
// out). -nmatsakis
let
_
=
infcx
.ignore_region_obligations
(
body_id
);
let
_
=
infcx
.ignore_region_obligations
();
infcx
.resolve_regions_and_report_errors
(
region_context
,
&
region_scope_tree
,
&
free_regions
);
let
predicates
=
match
infcx
.fully_resolve
(
&
predicates
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录