Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
2c17af0b
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,发现更多精彩内容 >>
提交
2c17af0b
编写于
11月 20, 2018
作者:
N
Niko Matsakis
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
track if any region constraints involved placeholders
上级
13ea9b87
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
33 addition
and
14 deletion
+33
-14
src/librustc/infer/mod.rs
src/librustc/infer/mod.rs
+6
-1
src/librustc/infer/region_constraints/mod.rs
src/librustc/infer/region_constraints/mod.rs
+24
-9
src/librustc/traits/select.rs
src/librustc/traits/select.rs
+3
-4
未找到文件。
src/librustc/infer/mod.rs
浏览文件 @
2c17af0b
...
...
@@ -867,10 +867,15 @@ pub fn probe<R, F>(&self, f: F) -> R
r
}
/// Scan the constraints produced since `snapshot` began and returns:
///
/// - None -- if none of them involve "region outlives" constraints
/// - Some(true) -- if there are `'a: 'b` constraints where `'a` or `'b` is a placehodler
/// - Some(false) -- if there are `'a: 'b` constraints but none involve placeholders
pub
fn
region_constraints_added_in_snapshot
(
&
self
,
snapshot
:
&
CombinedSnapshot
<
'a
,
'tcx
>
,
)
->
bool
{
)
->
Option
<
bool
>
{
self
.borrow_region_constraints
()
.region_constraints_added_in_snapshot
(
&
snapshot
.region_constraints_snapshot
,
)
...
...
src/librustc/infer/region_constraints/mod.rs
浏览文件 @
2c17af0b
...
...
@@ -128,6 +128,16 @@ pub enum Constraint<'tcx> {
RegSubReg
(
Region
<
'tcx
>
,
Region
<
'tcx
>
),
}
impl
Constraint
<
'_
>
{
pub
fn
involves_placeholders
(
&
self
)
->
bool
{
match
self
{
Constraint
::
VarSubVar
(
_
,
_
)
=>
false
,
Constraint
::
VarSubReg
(
_
,
r
)
|
Constraint
::
RegSubVar
(
r
,
_
)
=>
r
.is_placeholder
(),
Constraint
::
RegSubReg
(
r
,
s
)
=>
r
.is_placeholder
()
||
s
.is_placeholder
(),
}
}
}
/// VerifyGenericBound(T, _, R, RS): The parameter type `T` (or
/// associated type) must outlive the region `R`. `T` is known to
/// outlive `RS`. Therefore verify that `R <= RS[i]` for some
...
...
@@ -324,6 +334,8 @@ pub fn both() -> Self {
}
}
pub
struct
ConstraintInfo
{}
impl
<
'tcx
>
RegionConstraintCollector
<
'tcx
>
{
pub
fn
new
()
->
Self
{
Self
::
default
()
...
...
@@ -485,7 +497,8 @@ pub fn new_region_var(
)
->
RegionVid
{
let
vid
=
self
.var_infos
.push
(
RegionVariableInfo
{
origin
,
universe
});
let
u_vid
=
self
.unification_table
let
u_vid
=
self
.unification_table
.new_key
(
unify_key
::
RegionVidKey
{
min_vid
:
vid
});
assert_eq!
(
vid
,
u_vid
);
if
self
.in_snapshot
()
{
...
...
@@ -517,7 +530,8 @@ pub fn pop_placeholders(&mut self, placeholders: &FxHashSet<ty::Region<'tcx>>) {
assert
!
(
self
.in_snapshot
());
let
constraints_to_kill
:
Vec
<
usize
>
=
self
.undo_log
let
constraints_to_kill
:
Vec
<
usize
>
=
self
.undo_log
.iter
()
.enumerate
()
.rev
()
...
...
@@ -820,17 +834,18 @@ pub fn vars_created_since_snapshot(&self, mark: &RegionSnapshot) -> Vec<RegionVi
.filter_map
(|
&
elt
|
match
elt
{
AddVar
(
vid
)
=>
Some
(
vid
),
_
=>
None
,
})
.collect
()
})
.collect
()
}
pub
fn
region_constraints_added_in_snapshot
(
&
self
,
mark
:
&
RegionSnapshot
)
->
bool
{
/// See [`RegionInference::region_constraints_added_in_snapshot`]
pub
fn
region_constraints_added_in_snapshot
(
&
self
,
mark
:
&
RegionSnapshot
)
->
Option
<
bool
>
{
self
.undo_log
[
mark
.length
..
]
.iter
()
.any
(|
&
elt
|
match
elt
{
AddConstraint
(
_
)
=>
true
,
_
=>
false
,
})
.map
(|
&
elt
|
match
elt
{
AddConstraint
(
constraint
)
=>
Some
(
constraint
.involves_placeholders
()),
_
=>
None
,
})
.max
()
.unwrap_or
(
None
)
}
}
...
...
src/librustc/traits/select.rs
浏览文件 @
2c17af0b
...
...
@@ -639,10 +639,9 @@ fn evaluation_probe(
)
->
Result
<
EvaluationResult
,
OverflowError
>
{
self
.infcx
.probe
(|
snapshot
|
->
Result
<
EvaluationResult
,
OverflowError
>
{
let
result
=
op
(
self
)
?
;
if
!
self
.infcx
.region_constraints_added_in_snapshot
(
snapshot
)
{
Ok
(
result
)
}
else
{
Ok
(
result
.max
(
EvaluatedToOkModuloRegions
))
match
self
.infcx
.region_constraints_added_in_snapshot
(
snapshot
)
{
None
=>
Ok
(
result
),
Some
(
_
)
=>
Ok
(
result
.max
(
EvaluatedToOkModuloRegions
)),
}
})
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录