Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
be27a5a7
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,发现更多精彩内容 >>
提交
be27a5a7
编写于
6月 08, 2018
作者:
N
Niko Matsakis
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
make one `Canonicalize` impl for `QueryResult`
This lets us simplify a few type aliases.
上级
7358931a
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
37 addition
and
49 deletion
+37
-49
src/librustc/infer/canonical/mod.rs
src/librustc/infer/canonical/mod.rs
+28
-11
src/librustc/infer/canonical/query_result.rs
src/librustc/infer/canonical/query_result.rs
+7
-10
src/librustc/traits/query/dropck_outlives.rs
src/librustc/traits/query/dropck_outlives.rs
+1
-14
src/librustc/traits/query/normalize.rs
src/librustc/traits/query/normalize.rs
+1
-14
未找到文件。
src/librustc/infer/canonical/mod.rs
浏览文件 @
be27a5a7
...
...
@@ -32,15 +32,15 @@
//! [c]: https://rust-lang-nursery.github.io/rustc-guide/traits/canonicalization.html
use
infer
::{
InferCtxt
,
RegionVariableOrigin
,
TypeVariableOrigin
};
use
rustc_data_structures
::
indexed_vec
::
IndexVec
;
use
rustc_data_structures
::
sync
::
Lrc
;
use
serialize
::
UseSpecializedDecodable
;
use
std
::
fmt
::
Debug
;
use
std
::
ops
::
Index
;
use
syntax
::
codemap
::
Span
;
use
ty
::{
self
,
CanonicalVar
,
Lift
,
Region
,
Slice
,
TyCtxt
};
use
ty
::
subst
::
Kind
;
use
ty
::
fold
::
TypeFoldable
;
use
rustc_data_structures
::
indexed_vec
::
IndexVec
;
use
ty
::
subst
::
Kind
;
use
ty
::{
self
,
CanonicalVar
,
Lift
,
Region
,
Slice
,
TyCtxt
}
;
mod
canonicalizer
;
...
...
@@ -59,7 +59,7 @@ pub struct Canonical<'gcx, V> {
pub
type
CanonicalVarInfos
<
'gcx
>
=
&
'gcx
Slice
<
CanonicalVarInfo
>
;
impl
<
'gcx
>
UseSpecializedDecodable
for
CanonicalVarInfos
<
'gcx
>
{
}
impl
<
'gcx
>
UseSpecializedDecodable
for
CanonicalVarInfos
<
'gcx
>
{}
/// A set of values corresponding to the canonical variables from some
/// `Canonical`. You can give these values to
...
...
@@ -124,6 +124,9 @@ pub struct QueryResult<'tcx, R> {
pub
value
:
R
,
}
pub
type
CanonicalizedQueryResult
<
'gcx
,
T
>
=
Lrc
<
Canonical
<
'gcx
,
QueryResult
<
'gcx
,
<
T
as
Lift
<
'gcx
>>
::
Lifted
>>>
;
/// Indicates whether or not we were able to prove the query to be
/// true.
#[derive(Copy,
Clone,
Debug)]
...
...
@@ -246,9 +249,7 @@ fn fresh_inference_var_for_canonical_var(
CanonicalVarKind
::
Ty
(
ty_kind
)
=>
{
let
ty
=
match
ty_kind
{
CanonicalTyVarKind
::
General
=>
{
self
.next_ty_var
(
TypeVariableOrigin
::
MiscVariable
(
span
),
)
self
.next_ty_var
(
TypeVariableOrigin
::
MiscVariable
(
span
))
}
CanonicalTyVarKind
::
Int
=>
self
.tcx
.mk_int_var
(
self
.next_int_var_id
()),
...
...
@@ -258,9 +259,9 @@ fn fresh_inference_var_for_canonical_var(
ty
.into
()
}
CanonicalVarKind
::
Region
=>
{
self
.next_region_var
(
RegionVariableOrigin
::
MiscVariable
(
span
))
.into
(
)
}
CanonicalVarKind
::
Region
=>
self
.next_region_var
(
RegionVariableOrigin
::
MiscVariable
(
span
)
)
.into
(),
}
}
}
...
...
@@ -343,3 +344,19 @@ fn index(&self, value: CanonicalVar) -> &Kind<'tcx> {
&
self
.var_values
[
value
]
}
}
impl
<
'gcx
:
'tcx
,
'tcx
,
T
>
Canonicalize
<
'gcx
,
'tcx
>
for
QueryResult
<
'tcx
,
T
>
where
T
:
TypeFoldable
<
'tcx
>
+
Lift
<
'gcx
>
,
T
::
Lifted
:
Debug
,
{
// we ought to intern this, but I'm too lazy just now
type
Canonicalized
=
Lrc
<
Canonical
<
'gcx
,
QueryResult
<
'gcx
,
T
::
Lifted
>>>
;
fn
intern
(
_
gcx
:
TyCtxt
<
'_
,
'gcx
,
'gcx
>
,
value
:
Canonical
<
'gcx
,
Self
::
Lifted
>
,
)
->
Self
::
Canonicalized
{
Lrc
::
new
(
value
)
}
}
src/librustc/infer/canonical/query_result.rs
浏览文件 @
be27a5a7
...
...
@@ -19,11 +19,13 @@
use
infer
::
canonical
::
substitute
::
substitute_value
;
use
infer
::
canonical
::{
Canonical
,
CanonicalVarValues
,
Canonicalize
,
Certainty
,
QueryRegionConstraint
,
QueryResult
,
Canonical
,
CanonicalVarValues
,
Canonicalize
,
CanonicalizedQueryResult
,
Certainty
,
QueryRegionConstraint
,
QueryResult
,
};
use
infer
::
region_constraints
::{
Constraint
,
RegionConstraintData
};
use
infer
::{
InferCtxt
,
InferOk
,
InferResult
,
RegionObligation
};
use
rustc_data_structures
::
indexed_vec
::
Idx
;
use
rustc_data_structures
::
indexed_vec
::
IndexVec
;
use
std
::
fmt
::
Debug
;
use
syntax
::
ast
;
use
traits
::
query
::
NoSolution
;
...
...
@@ -31,12 +33,7 @@
use
traits
::{
Obligation
,
ObligationCause
,
PredicateObligation
};
use
ty
::
fold
::
TypeFoldable
;
use
ty
::
subst
::{
Kind
,
UnpackedKind
};
use
ty
::{
self
,
CanonicalVar
,
TyCtxt
};
use
rustc_data_structures
::
indexed_vec
::
IndexVec
;
type
CanonicalizedQueryResult
<
'gcx
,
'tcx
,
T
>
=
<
QueryResult
<
'tcx
,
T
>
as
Canonicalize
<
'gcx
,
'tcx
>>
::
Canonicalized
;
use
ty
::{
self
,
CanonicalVar
,
Lift
,
TyCtxt
};
impl
<
'cx
,
'gcx
,
'tcx
>
InferCtxt
<
'cx
,
'gcx
,
'tcx
>
{
/// This method is meant to be invoked as the final step of a canonical query
...
...
@@ -63,10 +60,10 @@ pub fn make_canonicalized_query_result<T>(
inference_vars
:
CanonicalVarValues
<
'tcx
>
,
answer
:
T
,
fulfill_cx
:
&
mut
FulfillmentContext
<
'tcx
>
,
)
->
Result
<
CanonicalizedQueryResult
<
'gcx
,
'tcx
,
T
>
,
NoSolution
>
)
->
Result
<
CanonicalizedQueryResult
<
'gcx
,
T
>
,
NoSolution
>
where
T
:
Debug
,
QueryResult
<
'tcx
,
T
>
:
Canonicalize
<
'gcx
,
'tcx
>
,
T
:
Debug
+
Lift
<
'gcx
>
+
TypeFoldable
<
'tcx
>
,
T
::
Lifted
:
Debug
,
{
let
query_result
=
self
.make_query_result
(
inference_vars
,
answer
,
fulfill_cx
)
?
;
let
(
canonical_result
,
_
)
=
self
.canonicalize_response
(
&
query_result
);
...
...
src/librustc/traits/query/dropck_outlives.rs
浏览文件 @
be27a5a7
...
...
@@ -9,13 +9,12 @@
// except according to those terms.
use
infer
::
at
::
At
;
use
infer
::
canonical
::{
Canonical
,
Canonicalize
,
QueryResult
};
use
infer
::
canonical
::{
Canonical
,
Canonicalize
};
use
infer
::
InferOk
;
use
std
::
iter
::
FromIterator
;
use
traits
::
query
::
CanonicalTyGoal
;
use
ty
::{
self
,
Ty
,
TyCtxt
};
use
ty
::
subst
::
Kind
;
use
rustc_data_structures
::
sync
::
Lrc
;
impl
<
'cx
,
'gcx
,
'tcx
>
At
<
'cx
,
'gcx
,
'tcx
>
{
/// Given a type `ty` of some value being dropped, computes a set
...
...
@@ -181,18 +180,6 @@ impl<'a, 'tcx> Lift<'tcx> for DropckOutlivesResult<'a> {
kinds
,
overflows
});
impl
<
'gcx
:
'tcx
,
'tcx
>
Canonicalize
<
'gcx
,
'tcx
>
for
QueryResult
<
'tcx
,
DropckOutlivesResult
<
'tcx
>>
{
// we ought to intern this, but I'm too lazy just now
type
Canonicalized
=
Lrc
<
Canonical
<
'gcx
,
QueryResult
<
'gcx
,
DropckOutlivesResult
<
'gcx
>>>>
;
fn
intern
(
_
gcx
:
TyCtxt
<
'_
,
'gcx
,
'gcx
>
,
value
:
Canonical
<
'gcx
,
Self
::
Lifted
>
,
)
->
Self
::
Canonicalized
{
Lrc
::
new
(
value
)
}
}
impl_stable_hash_for!
(
struct
DtorckConstraint
<
'tcx
>
{
outlives
,
dtorck_types
,
...
...
src/librustc/traits/query/normalize.rs
浏览文件 @
be27a5a7
...
...
@@ -14,10 +14,9 @@
use
infer
::{
InferCtxt
,
InferOk
};
use
infer
::
at
::
At
;
use
infer
::
canonical
::{
Canonical
,
Canonicalize
,
QueryResult
};
use
infer
::
canonical
::{
Canonical
,
Canonicalize
};
use
middle
::
const_val
::
ConstVal
;
use
mir
::
interpret
::
GlobalId
;
use
rustc_data_structures
::
sync
::
Lrc
;
use
traits
::{
Obligation
,
ObligationCause
,
PredicateObligation
,
Reveal
};
use
traits
::
query
::
CanonicalProjectionGoal
;
use
traits
::
project
::
Normalized
;
...
...
@@ -262,18 +261,6 @@ fn intern(
}
}
impl
<
'gcx
:
'tcx
,
'tcx
>
Canonicalize
<
'gcx
,
'tcx
>
for
QueryResult
<
'tcx
,
NormalizationResult
<
'tcx
>>
{
// we ought to intern this, but I'm too lazy just now
type
Canonicalized
=
Lrc
<
Canonical
<
'gcx
,
QueryResult
<
'gcx
,
NormalizationResult
<
'gcx
>>>>
;
fn
intern
(
_
gcx
:
TyCtxt
<
'_
,
'gcx
,
'gcx
>
,
value
:
Canonical
<
'gcx
,
Self
::
Lifted
>
,
)
->
Self
::
Canonicalized
{
Lrc
::
new
(
value
)
}
}
impl_stable_hash_for!
(
struct
NormalizationResult
<
'tcx
>
{
normalized_ty
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录