Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
09bba9b8
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,发现更多精彩内容 >>
提交
09bba9b8
编写于
6月 03, 2019
作者:
N
Niko Matsakis
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
introduce `QueryRegionConstraints` struct
上级
7e66a96d
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
43 addition
and
32 deletion
+43
-32
src/librustc/infer/canonical/mod.rs
src/librustc/infer/canonical/mod.rs
+9
-1
src/librustc/infer/canonical/query_response.rs
src/librustc/infer/canonical/query_response.rs
+6
-8
src/librustc/traits/query/type_op/custom.rs
src/librustc/traits/query/type_op/custom.rs
+6
-6
src/librustc/traits/query/type_op/mod.rs
src/librustc/traits/query/type_op/mod.rs
+7
-7
src/librustc_mir/borrow_check/nll/type_check/free_region_relations.rs
..._mir/borrow_check/nll/type_check/free_region_relations.rs
+4
-3
src/librustc_mir/borrow_check/nll/type_check/liveness/trace.rs
...ibrustc_mir/borrow_check/nll/type_check/liveness/trace.rs
+2
-2
src/librustc_mir/borrow_check/nll/type_check/mod.rs
src/librustc_mir/borrow_check/nll/type_check/mod.rs
+9
-5
未找到文件。
src/librustc/infer/canonical/mod.rs
浏览文件 @
09bba9b8
...
...
@@ -196,7 +196,15 @@ pub struct QueryResponse<'tcx, R> {
#[derive(Clone,
Debug,
Default,
HashStable)]
pub
struct
QueryRegionConstraints
<
'tcx
>
{
outlives
:
Vec
<
QueryOutlivesConstraint
<
'tcx
>>
,
pub
outlives
:
Vec
<
QueryOutlivesConstraint
<
'tcx
>>
,
}
impl
QueryRegionConstraints
<
'_
>
{
/// Represents an empty (trivially true) set of region
/// constraints.
pub
fn
is_empty
(
&
self
)
->
bool
{
self
.outlives
.is_empty
()
}
}
pub
type
Canonicalized
<
'tcx
,
V
>
=
Canonical
<
'tcx
,
V
>
;
...
...
src/librustc/infer/canonical/query_response.rs
浏览文件 @
09bba9b8
...
...
@@ -173,8 +173,8 @@ fn make_query_response<T>(
debug!
(
"ambig_errors = {:#?}"
,
ambig_errors
);
let
region_obligations
=
self
.take_registered_region_obligations
();
let
outlives
_constraints
=
self
.with_region_constraints
(|
region_constraints
|
{
make_query_
outlive
s
(
let
region
_constraints
=
self
.with_region_constraints
(|
region_constraints
|
{
make_query_
region_constraint
s
(
tcx
,
region_obligations
.iter
()
...
...
@@ -191,9 +191,7 @@ fn make_query_response<T>(
Ok
(
QueryResponse
{
var_values
:
inference_vars
,
region_constraints
:
QueryRegionConstraints
{
outlives
:
outlives_constraints
,
},
region_constraints
,
certainty
,
value
:
answer
,
})
...
...
@@ -647,11 +645,11 @@ fn unify_canonical_vars(
/// Given the region obligations and constraints scraped from the infcx,
/// creates query region constraints.
pub
fn
make_query_
outlive
s
<
'tcx
>
(
pub
fn
make_query_
region_constraint
s
<
'tcx
>
(
tcx
:
TyCtxt
<
'tcx
>
,
outlives_obligations
:
impl
Iterator
<
Item
=
(
Ty
<
'tcx
>
,
ty
::
Region
<
'tcx
>
)
>
,
region_constraints
:
&
RegionConstraintData
<
'tcx
>
,
)
->
Vec
<
QueryOutlivesConstraint
<
'tcx
>
>
{
)
->
QueryRegionConstraints
<
'tcx
>
{
let
RegionConstraintData
{
constraints
,
verifys
,
...
...
@@ -690,5 +688,5 @@ pub fn make_query_outlives<'tcx>(
)
.collect
();
outlives
QueryRegionConstraints
{
outlives
}
}
src/librustc/traits/query/type_op/custom.rs
浏览文件 @
09bba9b8
...
...
@@ -3,7 +3,7 @@
use
crate
::
traits
::
query
::
Fallible
;
use
crate
::
infer
::
canonical
::
query_response
;
use
crate
::
infer
::
canonical
::
Query
OutlivesConstraint
;
use
crate
::
infer
::
canonical
::
Query
RegionConstraints
;
use
std
::
rc
::
Rc
;
use
syntax
::
source_map
::
DUMMY_SP
;
use
crate
::
traits
::{
ObligationCause
,
TraitEngine
,
TraitEngineExt
};
...
...
@@ -39,7 +39,7 @@ impl<'tcx, F, R, G> super::TypeOp<'tcx> for CustomTypeOp<F, G>
fn
fully_perform
(
self
,
infcx
:
&
InferCtxt
<
'_
,
'tcx
>
,
)
->
Fallible
<
(
Self
::
Output
,
Option
<
Rc
<
Vec
<
QueryOutlivesConstraint
<
'tcx
>
>>>
)
>
{
)
->
Fallible
<
(
Self
::
Output
,
Option
<
Rc
<
QueryRegionConstraints
<
'tcx
>>>
)
>
{
if
cfg!
(
debug_assertions
)
{
info!
(
"fully_perform({:?})"
,
self
);
}
...
...
@@ -62,7 +62,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fn
scrape_region_constraints
<
'tcx
,
R
>
(
infcx
:
&
InferCtxt
<
'_
,
'tcx
>
,
op
:
impl
FnOnce
()
->
Fallible
<
InferOk
<
'tcx
,
R
>>
,
)
->
Fallible
<
(
R
,
Option
<
Rc
<
Vec
<
QueryOutlivesConstraint
<
'tcx
>
>>>
)
>
{
)
->
Fallible
<
(
R
,
Option
<
Rc
<
QueryRegionConstraints
<
'tcx
>>>
)
>
{
let
mut
fulfill_cx
=
TraitEngine
::
new
(
infcx
.tcx
);
let
dummy_body_id
=
ObligationCause
::
dummy
()
.body_id
;
...
...
@@ -92,7 +92,7 @@ fn scrape_region_constraints<'tcx, R>(
let
region_constraint_data
=
infcx
.take_and_reset_region_constraints
();
let
outlives
=
query_response
::
make_query_outlive
s
(
let
region_constraints
=
query_response
::
make_query_region_constraint
s
(
infcx
.tcx
,
region_obligations
.iter
()
...
...
@@ -101,9 +101,9 @@ fn scrape_region_constraints<'tcx, R>(
&
region_constraint_data
,
);
if
outlive
s
.is_empty
()
{
if
region_constraint
s
.is_empty
()
{
Ok
((
value
,
None
))
}
else
{
Ok
((
value
,
Some
(
Rc
::
new
(
outlive
s
))))
Ok
((
value
,
Some
(
Rc
::
new
(
region_constraint
s
))))
}
}
src/librustc/traits/query/type_op/mod.rs
浏览文件 @
09bba9b8
use
crate
::
infer
::
canonical
::{
Canonical
,
Canonicalized
,
CanonicalizedQueryResponse
,
OriginalQueryValues
,
QueryOutlivesConstraint
,
QueryResponse
,
Query
RegionConstraints
,
Query
OutlivesConstraint
,
QueryResponse
,
};
use
crate
::
infer
::{
InferCtxt
,
InferOk
};
use
std
::
fmt
;
...
...
@@ -32,7 +32,7 @@ pub trait TypeOp<'tcx>: Sized + fmt::Debug {
fn
fully_perform
(
self
,
infcx
:
&
InferCtxt
<
'_
,
'tcx
>
,
)
->
Fallible
<
(
Self
::
Output
,
Option
<
Rc
<
Vec
<
QueryOutlivesConstraint
<
'tcx
>
>>>
)
>
;
)
->
Fallible
<
(
Self
::
Output
,
Option
<
Rc
<
QueryRegionConstraints
<
'tcx
>>>
)
>
;
}
/// "Query type ops" are type ops that are implemented using a
...
...
@@ -140,16 +140,16 @@ impl<'tcx, Q> TypeOp<'tcx> for ParamEnvAnd<'tcx, Q>
fn
fully_perform
(
self
,
infcx
:
&
InferCtxt
<
'_
,
'tcx
>
,
)
->
Fallible
<
(
Self
::
Output
,
Option
<
Rc
<
Vec
<
QueryOutlivesConstraint
<
'tcx
>
>>>
)
>
{
let
mut
qrc
=
vec!
[];
let
r
=
Q
::
fully_perform_into
(
self
,
infcx
,
&
mut
qrc
)
?
;
)
->
Fallible
<
(
Self
::
Output
,
Option
<
Rc
<
QueryRegionConstraints
<
'tcx
>>>
)
>
{
let
mut
outlives
=
vec!
[];
let
r
=
Q
::
fully_perform_into
(
self
,
infcx
,
&
mut
outlives
)
?
;
// Promote the final query-region-constraints into a
// (optional) ref-counted vector:
let
opt_qrc
=
if
qrc
.is_empty
()
{
let
opt_qrc
=
if
outlives
.is_empty
()
{
None
}
else
{
Some
(
Rc
::
new
(
qrc
))
Some
(
Rc
::
new
(
QueryRegionConstraints
{
outlives
}
))
};
Ok
((
r
,
opt_qrc
))
...
...
src/librustc_mir/borrow_check/nll/type_check/free_region_relations.rs
浏览文件 @
09bba9b8
...
...
@@ -2,7 +2,7 @@
use
crate
::
borrow_check
::
nll
::
type_check
::{
Locations
,
MirTypeckRegionConstraints
};
use
crate
::
borrow_check
::
nll
::
universal_regions
::
UniversalRegions
;
use
crate
::
borrow_check
::
nll
::
ToRegionVid
;
use
rustc
::
infer
::
canonical
::
Query
OutlivesConstraint
;
use
rustc
::
infer
::
canonical
::
Query
RegionConstraints
;
use
rustc
::
infer
::
outlives
::
free_region_map
::
FreeRegionRelations
;
use
rustc
::
infer
::
region_constraints
::
GenericKind
;
use
rustc
::
infer
::
InferCtxt
;
...
...
@@ -288,6 +288,7 @@ impl UniversalRegionRelationsBuilder<'cx, 'tcx> {
}
for
data
in
constraint_sets
{
let
QueryRegionConstraints
{
outlives
}
=
&*
data
;
constraint_conversion
::
ConstraintConversion
::
new
(
self
.infcx
,
&
self
.universal_regions
,
...
...
@@ -297,7 +298,7 @@ impl UniversalRegionRelationsBuilder<'cx, 'tcx> {
Locations
::
All
(
DUMMY_SP
),
ConstraintCategory
::
Internal
,
&
mut
self
.constraints
,
)
.convert_all
(
&
data
);
)
.convert_all
(
outlives
);
}
CreateResult
{
...
...
@@ -311,7 +312,7 @@ impl UniversalRegionRelationsBuilder<'cx, 'tcx> {
/// either the return type of the MIR or one of its arguments. At
/// the same time, compute and add any implied bounds that come
/// from this local.
fn
add_implied_bounds
(
&
mut
self
,
ty
:
Ty
<
'tcx
>
)
->
Option
<
Rc
<
Vec
<
QueryOutlivesConstraint
<
'tcx
>
>>>
{
fn
add_implied_bounds
(
&
mut
self
,
ty
:
Ty
<
'tcx
>
)
->
Option
<
Rc
<
QueryRegionConstraints
<
'tcx
>>>
{
debug!
(
"add_implied_bounds(ty={:?})"
,
ty
);
let
(
bounds
,
constraints
)
=
self
.param_env
...
...
src/librustc_mir/borrow_check/nll/type_check/liveness/trace.rs
浏览文件 @
09bba9b8
...
...
@@ -6,7 +6,7 @@
use
crate
::
dataflow
::
indexes
::
MovePathIndex
;
use
crate
::
dataflow
::
move_paths
::
MoveData
;
use
crate
::
dataflow
::{
FlowAtLocation
,
FlowsAtLocation
,
MaybeInitializedPlaces
};
use
rustc
::
infer
::
canonical
::
Query
OutlivesConstraint
;
use
rustc
::
infer
::
canonical
::
Query
RegionConstraints
;
use
rustc
::
mir
::{
BasicBlock
,
ConstraintCategory
,
Local
,
Location
,
Body
};
use
rustc
::
traits
::
query
::
dropck_outlives
::
DropckOutlivesResult
;
use
rustc
::
traits
::
query
::
type_op
::
outlives
::
DropckOutlives
;
...
...
@@ -88,7 +88,7 @@ struct LivenessContext<'me, 'typeck, 'flow, 'tcx> {
struct
DropData
<
'tcx
>
{
dropck_result
:
DropckOutlivesResult
<
'tcx
>
,
region_constraint_data
:
Option
<
Rc
<
Vec
<
QueryOutlivesConstraint
<
'tcx
>
>>>
,
region_constraint_data
:
Option
<
Rc
<
QueryRegionConstraints
<
'tcx
>>>
,
}
struct
LivenessResults
<
'me
,
'typeck
,
'flow
,
'tcx
>
{
...
...
src/librustc_mir/borrow_check/nll/type_check/mod.rs
浏览文件 @
09bba9b8
...
...
@@ -23,7 +23,7 @@
use
either
::
Either
;
use
rustc
::
hir
;
use
rustc
::
hir
::
def_id
::
DefId
;
use
rustc
::
infer
::
canonical
::
Query
OutlivesConstraint
;
use
rustc
::
infer
::
canonical
::
Query
RegionConstraints
;
use
rustc
::
infer
::
outlives
::
env
::
RegionBoundPairs
;
use
rustc
::
infer
::{
InferCtxt
,
InferOk
,
LateBoundRegionConversionTime
,
NLLRegionVariableOrigin
};
use
rustc
::
infer
::
type_variable
::{
TypeVariableOrigin
,
TypeVariableOriginKind
};
...
...
@@ -1093,13 +1093,15 @@ fn push_region_constraints(
&
mut
self
,
locations
:
Locations
,
category
:
ConstraintCategory
,
data
:
&
[
QueryOutlivesConstraint
<
'tcx
>
]
,
data
:
&
QueryRegionConstraints
<
'tcx
>
,
)
{
debug!
(
"push_region_constraints: constraints generated at {:?} are {:#?}"
,
locations
,
data
);
let
QueryRegionConstraints
{
outlives
}
=
data
;
constraint_conversion
::
ConstraintConversion
::
new
(
self
.infcx
,
self
.borrowck_context.universal_regions
,
...
...
@@ -1109,7 +1111,7 @@ fn push_region_constraints(
locations
,
category
,
&
mut
self
.borrowck_context.constraints
,
)
.convert_all
(
&
data
);
)
.convert_all
(
outlives
);
}
/// Convenient wrapper around `relate_tys::relate_types` -- see
...
...
@@ -2508,10 +2510,12 @@ fn prove_closure_bounds(
location
:
Location
,
)
->
ty
::
InstantiatedPredicates
<
'tcx
>
{
if
let
Some
(
closure_region_requirements
)
=
tcx
.mir_borrowck
(
def_id
)
.closure_requirements
{
let
closure_constraints
=
closure_region_requirements
.apply_requirements
(
tcx
,
def_id
,
substs
);
let
closure_constraints
=
QueryRegionConstraints
{
outlives
:
closure_region_requirements
.apply_requirements
(
tcx
,
def_id
,
substs
)
};
let
bounds_mapping
=
closure_constraints
.outlives
.iter
()
.enumerate
()
.filter_map
(|(
idx
,
constraint
)|
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录