Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
7c8887cc
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,发现更多精彩内容 >>
提交
7c8887cc
编写于
10月 23, 2018
作者:
N
Niko Matsakis
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
introduce (but do not use) `ascribe_user_type` goal
Lots of annoying boilerplate.
上级
f99911a4
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
133 addition
and
8 deletion
+133
-8
src/librustc/dep_graph/dep_node.rs
src/librustc/dep_graph/dep_node.rs
+4
-2
src/librustc/mir/mod.rs
src/librustc/mir/mod.rs
+8
-0
src/librustc/traits/query/mod.rs
src/librustc/traits/query/mod.rs
+3
-0
src/librustc/traits/query/type_op/ascribe_user_type.rs
src/librustc/traits/query/type_op/ascribe_user_type.rs
+74
-0
src/librustc/traits/query/type_op/mod.rs
src/librustc/traits/query/type_op/mod.rs
+1
-0
src/librustc/ty/mod.rs
src/librustc/ty/mod.rs
+1
-1
src/librustc/ty/query/config.rs
src/librustc/ty/query/config.rs
+12
-2
src/librustc/ty/query/mod.rs
src/librustc/ty/query/mod.rs
+14
-3
src/librustc/ty/query/plumbing.rs
src/librustc/ty/query/plumbing.rs
+1
-0
src/librustc_mir/borrow_check/nll/type_check/mod.rs
src/librustc_mir/borrow_check/nll/type_check/mod.rs
+1
-0
src/librustc_traits/type_op.rs
src/librustc_traits/type_op.rs
+14
-0
未找到文件。
src/librustc/dep_graph/dep_node.rs
浏览文件 @
7c8887cc
...
...
@@ -72,8 +72,9 @@
use
syntax_pos
::
symbol
::
InternedString
;
use
traits
;
use
traits
::
query
::{
CanonicalProjectionGoal
,
CanonicalTyGoal
,
CanonicalTypeOpEqGoal
,
CanonicalTypeOpSubtypeGoal
,
CanonicalPredicateGoal
,
CanonicalTypeOpProvePredicateGoal
,
CanonicalTypeOpNormalizeGoal
,
CanonicalProjectionGoal
,
CanonicalTyGoal
,
CanonicalTypeOpAscribeUserTypeGoal
,
CanonicalTypeOpEqGoal
,
CanonicalTypeOpSubtypeGoal
,
CanonicalPredicateGoal
,
CanonicalTypeOpProvePredicateGoal
,
CanonicalTypeOpNormalizeGoal
,
};
use
ty
::{
TyCtxt
,
FnSig
,
Instance
,
InstanceDef
,
ParamEnv
,
ParamEnvAnd
,
Predicate
,
PolyFnSig
,
PolyTraitRef
,
Ty
};
...
...
@@ -654,6 +655,7 @@ pub fn fingerprint_needed_for_crate_hash(self) -> bool {
[]
ImpliedOutlivesBounds
(
CanonicalTyGoal
<
'tcx
>
),
[]
DropckOutlives
(
CanonicalTyGoal
<
'tcx
>
),
[]
EvaluateObligation
(
CanonicalPredicateGoal
<
'tcx
>
),
[]
TypeOpAscribeUserType
(
CanonicalTypeOpAscribeUserTypeGoal
<
'tcx
>
),
[]
TypeOpEq
(
CanonicalTypeOpEqGoal
<
'tcx
>
),
[]
TypeOpSubtype
(
CanonicalTypeOpSubtypeGoal
<
'tcx
>
),
[]
TypeOpProvePredicate
(
CanonicalTypeOpProvePredicateGoal
<
'tcx
>
),
...
...
src/librustc/mir/mod.rs
浏览文件 @
7c8887cc
...
...
@@ -2438,6 +2438,14 @@ impl<'tcx> TypeFoldable<'tcx> for UserTypeAnnotation<'tcx> {
}
}
EnumLiftImpl!
{
impl
<
'a
,
'tcx
>
Lift
<
'tcx
>
for
UserTypeAnnotation
<
'a
>
{
type
Lifted
=
UserTypeAnnotation
<
'tcx
>
;
(
UserTypeAnnotation
::
Ty
)(
ty
),
(
UserTypeAnnotation
::
TypeOf
)(
def
,
substs
),
}
}
newtype_index!
{
pub
struct
Promoted
{
DEBUG_FORMAT
=
"promoted[{}]"
...
...
src/librustc/traits/query/mod.rs
浏览文件 @
7c8887cc
...
...
@@ -34,6 +34,9 @@
pub
type
CanonicalPredicateGoal
<
'tcx
>
=
Canonical
<
'tcx
,
ty
::
ParamEnvAnd
<
'tcx
,
ty
::
Predicate
<
'tcx
>>>
;
pub
type
CanonicalTypeOpAscribeUserTypeGoal
<
'tcx
>
=
Canonical
<
'tcx
,
ty
::
ParamEnvAnd
<
'tcx
,
type_op
::
ascribe_user_type
::
AscribeUserType
<
'tcx
>>>
;
pub
type
CanonicalTypeOpEqGoal
<
'tcx
>
=
Canonical
<
'tcx
,
ty
::
ParamEnvAnd
<
'tcx
,
type_op
::
eq
::
Eq
<
'tcx
>>>
;
...
...
src/librustc/traits/query/type_op/ascribe_user_type.rs
0 → 100644
浏览文件 @
7c8887cc
// Copyright 2016 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
infer
::
canonical
::{
Canonical
,
Canonicalized
,
CanonicalizedQueryResponse
,
QueryResponse
};
use
mir
::
UserTypeAnnotation
;
use
traits
::
query
::
Fallible
;
use
ty
::{
self
,
ParamEnvAnd
,
Ty
,
TyCtxt
};
#[derive(Copy,
Clone,
Debug,
Hash,
PartialEq,
Eq)]
pub
struct
AscribeUserType
<
'tcx
>
{
pub
mir_ty
:
Ty
<
'tcx
>
,
pub
variance
:
ty
::
Variance
,
pub
user_ty
:
UserTypeAnnotation
<
'tcx
>
,
}
impl
<
'tcx
>
AscribeUserType
<
'tcx
>
{
pub
fn
new
(
mir_ty
:
Ty
<
'tcx
>
,
variance
:
ty
::
Variance
,
user_ty
:
UserTypeAnnotation
<
'tcx
>
,
)
->
Self
{
AscribeUserType
{
mir_ty
,
variance
,
user_ty
}
}
}
impl
<
'gcx
:
'tcx
,
'tcx
>
super
::
QueryTypeOp
<
'gcx
,
'tcx
>
for
AscribeUserType
<
'tcx
>
{
type
QueryResponse
=
();
fn
try_fast_path
(
_
tcx
:
TyCtxt
<
'_
,
'gcx
,
'tcx
>
,
_
key
:
&
ParamEnvAnd
<
'tcx
,
Self
>
,
)
->
Option
<
Self
::
QueryResponse
>
{
None
}
fn
perform_query
(
tcx
:
TyCtxt
<
'_
,
'gcx
,
'tcx
>
,
canonicalized
:
Canonicalized
<
'gcx
,
ParamEnvAnd
<
'tcx
,
Self
>>
,
)
->
Fallible
<
CanonicalizedQueryResponse
<
'gcx
,
()
>>
{
tcx
.type_op_ascribe_user_type
(
canonicalized
)
}
fn
shrink_to_tcx_lifetime
(
v
:
&
'a
CanonicalizedQueryResponse
<
'gcx
,
()
>
,
)
->
&
'a
Canonical
<
'tcx
,
QueryResponse
<
'tcx
,
()
>>
{
v
}
}
BraceStructTypeFoldableImpl!
{
impl
<
'tcx
>
TypeFoldable
<
'tcx
>
for
AscribeUserType
<
'tcx
>
{
mir_ty
,
variance
,
user_ty
}
}
BraceStructLiftImpl!
{
impl
<
'a
,
'tcx
>
Lift
<
'tcx
>
for
AscribeUserType
<
'a
>
{
type
Lifted
=
AscribeUserType
<
'tcx
>
;
mir_ty
,
variance
,
user_ty
}
}
impl_stable_hash_for!
{
struct
AscribeUserType
<
'tcx
>
{
mir_ty
,
variance
,
user_ty
}
}
src/librustc/traits/query/type_op/mod.rs
浏览文件 @
7c8887cc
...
...
@@ -20,6 +20,7 @@
use
ty
::
fold
::
TypeFoldable
;
use
ty
::{
Lift
,
ParamEnvAnd
,
TyCtxt
};
pub
mod
ascribe_user_type
;
pub
mod
custom
;
pub
mod
eq
;
pub
mod
implied_outlives_bounds
;
...
...
src/librustc/ty/mod.rs
浏览文件 @
7c8887cc
...
...
@@ -328,7 +328,7 @@ pub fn is_visible_locally(self) -> bool {
}
}
#[derive(C
lone,
PartialEq,
RustcDecodable,
RustcEncodable,
Copy
)]
#[derive(C
opy,
Clone,
PartialEq,
Eq,
RustcDecodable,
RustcEncodable,
Hash
)]
pub
enum
Variance
{
Covariant
,
// T<A> <: T<B> iff A <: B -- e.g., function return type
Invariant
,
// T<A> <: T<B> iff B == A -- e.g., type of mutable cell
...
...
src/librustc/ty/query/config.rs
浏览文件 @
7c8887cc
...
...
@@ -14,8 +14,9 @@
use
mir
::
interpret
::
GlobalId
;
use
traits
;
use
traits
::
query
::{
CanonicalPredicateGoal
,
CanonicalProjectionGoal
,
CanonicalTyGoal
,
CanonicalTypeOpEqGoal
,
CanonicalTypeOpNormalizeGoal
,
CanonicalTypeOpProvePredicateGoal
,
CanonicalTypeOpSubtypeGoal
,
CanonicalPredicateGoal
,
CanonicalProjectionGoal
,
CanonicalTyGoal
,
CanonicalTypeOpAscribeUserTypeGoal
,
CanonicalTypeOpEqGoal
,
CanonicalTypeOpNormalizeGoal
,
CanonicalTypeOpProvePredicateGoal
,
CanonicalTypeOpSubtypeGoal
,
};
use
ty
::{
self
,
ParamEnvAnd
,
Ty
,
TyCtxt
};
use
ty
::
subst
::
Substs
;
...
...
@@ -115,6 +116,15 @@ fn describe(_tcx: TyCtxt<'_, '_, '_>, goal: CanonicalPredicateGoal<'tcx>) -> Cow
}
}
impl
<
'tcx
>
QueryDescription
<
'tcx
>
for
queries
::
type_op_ascribe_user_type
<
'tcx
>
{
fn
describe
(
_
tcx
:
TyCtxt
<
'_
,
'_
,
'_
>
,
goal
:
CanonicalTypeOpAscribeUserTypeGoal
<
'tcx
>
,
)
->
Cow
<
'static
,
str
>
{
format!
(
"evaluating `type_op_ascribe_user_type` `{:?}`"
,
goal
)
.into
()
}
}
impl
<
'tcx
>
QueryDescription
<
'tcx
>
for
queries
::
type_op_eq
<
'tcx
>
{
fn
describe
(
_
tcx
:
TyCtxt
<
'_
,
'_
,
'_
>
,
goal
:
CanonicalTypeOpEqGoal
<
'tcx
>
)
->
Cow
<
'static
,
str
>
{
format!
(
"evaluating `type_op_eq` `{:?}`"
,
goal
)
.into
()
...
...
src/librustc/ty/query/mod.rs
浏览文件 @
7c8887cc
...
...
@@ -34,9 +34,12 @@
use
session
::{
CompileResult
,
CrateDisambiguator
};
use
session
::
config
::
OutputFilenames
;
use
traits
::{
self
,
Vtable
};
use
traits
::
query
::{
CanonicalPredicateGoal
,
CanonicalProjectionGoal
,
CanonicalTyGoal
,
CanonicalTypeOpEqGoal
,
CanonicalTypeOpSubtypeGoal
,
CanonicalTypeOpProvePredicateGoal
,
CanonicalTypeOpNormalizeGoal
,
NoSolution
};
use
traits
::
query
::{
CanonicalPredicateGoal
,
CanonicalProjectionGoal
,
CanonicalTyGoal
,
CanonicalTypeOpAscribeUserTypeGoal
,
CanonicalTypeOpEqGoal
,
CanonicalTypeOpSubtypeGoal
,
CanonicalTypeOpProvePredicateGoal
,
CanonicalTypeOpNormalizeGoal
,
NoSolution
,
};
use
traits
::
query
::
dropck_outlives
::{
DtorckConstraint
,
DropckOutlivesResult
};
use
traits
::
query
::
normalize
::
NormalizationResult
;
use
traits
::
query
::
outlives_bounds
::
OutlivesBound
;
...
...
@@ -589,6 +592,14 @@
CanonicalPredicateGoal
<
'tcx
>
)
->
Result
<
traits
::
EvaluationResult
,
traits
::
OverflowError
>
,
/// Do not call this query directly: part of the `Eq` type-op
[]
fn
type_op_ascribe_user_type
:
TypeOpAscribeUserType
(
CanonicalTypeOpAscribeUserTypeGoal
<
'tcx
>
)
->
Result
<
Lrc
<
Canonical
<
'tcx
,
canonical
::
QueryResponse
<
'tcx
,
()
>>>
,
NoSolution
,
>
,
/// Do not call this query directly: part of the `Eq` type-op
[]
fn
type_op_eq
:
TypeOpEq
(
CanonicalTypeOpEqGoal
<
'tcx
>
...
...
src/librustc/ty/query/plumbing.rs
浏览文件 @
7c8887cc
...
...
@@ -1079,6 +1079,7 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>,
DepKind
::
ImpliedOutlivesBounds
|
DepKind
::
DropckOutlives
|
DepKind
::
EvaluateObligation
|
DepKind
::
TypeOpAscribeUserType
|
DepKind
::
TypeOpEq
|
DepKind
::
TypeOpSubtype
|
DepKind
::
TypeOpProvePredicate
|
...
...
src/librustc_mir/borrow_check/nll/type_check/mod.rs
浏览文件 @
7c8887cc
...
...
@@ -1008,6 +1008,7 @@ fn relate_type_and_user_type(
let
ty
=
self
.tcx
()
.type_of
(
def_id
);
let
ty
=
ty
.subst
(
tcx
,
substs
);
debug!
(
"relate_type_and_user_type: ty of def-id is {:?}"
,
ty
);
let
ty
=
self
.normalize
(
ty
,
locations
);
self
.relate_types
(
ty
,
v1
,
a
,
locations
,
category
)
?
;
...
...
src/librustc_traits/type_op.rs
浏览文件 @
7c8887cc
...
...
@@ -10,6 +10,7 @@
use
rustc
::
infer
::
canonical
::{
Canonical
,
QueryResponse
};
use
rustc
::
infer
::
InferCtxt
;
use
rustc
::
traits
::
query
::
type_op
::
ascribe_user_type
::
AscribeUserType
;
use
rustc
::
traits
::
query
::
type_op
::
eq
::
Eq
;
use
rustc
::
traits
::
query
::
type_op
::
normalize
::
Normalize
;
use
rustc
::
traits
::
query
::
type_op
::
prove_predicate
::
ProvePredicate
;
...
...
@@ -24,6 +25,7 @@
crate
fn
provide
(
p
:
&
mut
Providers
)
{
*
p
=
Providers
{
type_op_ascribe_user_type
,
type_op_eq
,
type_op_prove_predicate
,
type_op_subtype
,
...
...
@@ -35,6 +37,18 @@
};
}
fn
type_op_ascribe_user_type
<
'tcx
>
(
tcx
:
TyCtxt
<
'_
,
'tcx
,
'tcx
>
,
canonicalized
:
Canonical
<
'tcx
,
ParamEnvAnd
<
'tcx
,
AscribeUserType
<
'tcx
>>>
,
)
->
Result
<
Lrc
<
Canonical
<
'tcx
,
QueryResponse
<
'tcx
,
()
>>>
,
NoSolution
>
{
tcx
.infer_ctxt
()
.enter_canonical_trait_query
(
&
canonicalized
,
|
infcx
,
fulfill_cx
,
key
|
{
let
(
param_env
,
AscribeUserType
{
mir_ty
,
variance
,
user_ty
})
=
key
.into_parts
();
drop
((
infcx
,
fulfill_cx
,
param_env
,
mir_ty
,
variance
,
user_ty
));
Ok
(())
})
}
fn
type_op_eq
<
'tcx
>
(
tcx
:
TyCtxt
<
'_
,
'tcx
,
'tcx
>
,
canonicalized
:
Canonical
<
'tcx
,
ParamEnvAnd
<
'tcx
,
Eq
<
'tcx
>>>
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录