Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
cd9743b4
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,发现更多精彩内容 >>
提交
cd9743b4
编写于
7月 18, 2020
作者:
B
Bastian Kauschke
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
directly contain `PredicateAtom` in `PredicateKind::ForAll`
上级
d8cf8ba5
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
163 addition
and
180 deletion
+163
-180
src/librustc_infer/infer/canonical/query_response.rs
src/librustc_infer/infer/canonical/query_response.rs
+0
-2
src/librustc_middle/ty/flags.rs
src/librustc_middle/ty/flags.rs
+40
-41
src/librustc_middle/ty/mod.rs
src/librustc_middle/ty/mod.rs
+28
-36
src/librustc_middle/ty/print/pretty.rs
src/librustc_middle/ty/print/pretty.rs
+38
-36
src/librustc_trait_selection/traits/fulfill.rs
src/librustc_trait_selection/traits/fulfill.rs
+1
-0
src/librustc_trait_selection/traits/wf.rs
src/librustc_trait_selection/traits/wf.rs
+31
-36
src/librustc_typeck/check/method/probe.rs
src/librustc_typeck/check/method/probe.rs
+22
-18
src/librustc_typeck/check/mod.rs
src/librustc_typeck/check/mod.rs
+1
-4
src/librustc_typeck/collect.rs
src/librustc_typeck/collect.rs
+1
-4
src/librustc_typeck/outlives/mod.rs
src/librustc_typeck/outlives/mod.rs
+1
-3
未找到文件。
src/librustc_infer/infer/canonical/query_response.rs
浏览文件 @
cd9743b4
...
...
@@ -531,11 +531,9 @@ fn query_outlives_constraints_into_obligations<'a>(
let
predicate
=
match
k1
.unpack
()
{
GenericArgKind
::
Lifetime
(
r1
)
=>
{
ty
::
PredicateAtom
::
RegionOutlives
(
ty
::
OutlivesPredicate
(
r1
,
r2
))
.to_predicate
(
self
.tcx
)
}
GenericArgKind
::
Type
(
t1
)
=>
{
ty
::
PredicateAtom
::
TypeOutlives
(
ty
::
OutlivesPredicate
(
t1
,
r2
))
.to_predicate
(
self
.tcx
)
}
GenericArgKind
::
Const
(
..
)
=>
{
// Consts cannot outlive one another, so we don't expect to
...
...
src/librustc_middle/ty/flags.rs
浏览文件 @
cd9743b4
...
...
@@ -201,55 +201,54 @@ fn add_kind(&mut self, kind: &ty::TyKind<'_>) {
}
}
fn
add_predicate
(
&
mut
self
,
pred
:
ty
::
Predicate
<
'_
>
)
{
self
.add_flags
(
pred
.inner.flags
);
self
.add_exclusive_binder
(
pred
.inner.outer_exclusive_binder
);
}
fn
add_predicate_kind
(
&
mut
self
,
kind
:
&
ty
::
PredicateKind
<
'_
>
)
{
match
kind
{
ty
::
PredicateKind
::
ForAll
(
binder
)
=>
{
let
mut
computation
=
FlagComputation
::
new
();
computation
.add_predicate
(
binder
.skip_binder
());
computation
.add_predicate
_atom
(
binder
.skip_binder
());
self
.add_bound_computation
(
computation
);
}
&
ty
::
PredicateKind
::
Atom
(
atom
)
=>
match
atom
{
ty
::
PredicateAtom
::
Trait
(
trait_pred
,
_
constness
)
=>
{
self
.add_substs
(
trait_pred
.trait_ref.substs
);
}
ty
::
PredicateAtom
::
RegionOutlives
(
ty
::
OutlivesPredicate
(
a
,
b
))
=>
{
self
.add_region
(
a
);
self
.add_region
(
b
);
}
ty
::
PredicateAtom
::
TypeOutlives
(
ty
::
OutlivesPredicate
(
ty
,
region
))
=>
{
self
.add_ty
(
ty
);
self
.add_region
(
region
);
}
ty
::
PredicateAtom
::
Subtype
(
ty
::
SubtypePredicate
{
a_is_expected
:
_
,
a
,
b
})
=>
{
self
.add_ty
(
a
);
self
.add_ty
(
b
);
}
ty
::
PredicateAtom
::
Projection
(
ty
::
ProjectionPredicate
{
projection_ty
,
ty
})
=>
{
self
.add_projection_ty
(
projection_ty
);
self
.add_ty
(
ty
);
}
ty
::
PredicateAtom
::
WellFormed
(
arg
)
=>
{
self
.add_substs
(
slice
::
from_ref
(
&
arg
));
}
ty
::
PredicateAtom
::
ObjectSafe
(
_
def_id
)
=>
{}
ty
::
PredicateAtom
::
ClosureKind
(
_
def_id
,
substs
,
_
kind
)
=>
{
self
.add_substs
(
substs
);
}
ty
::
PredicateAtom
::
ConstEvaluatable
(
_
def_id
,
substs
)
=>
{
self
.add_substs
(
substs
);
}
ty
::
PredicateAtom
::
ConstEquate
(
expected
,
found
)
=>
{
self
.add_const
(
expected
);
self
.add_const
(
found
);
}
},
&
ty
::
PredicateKind
::
Atom
(
atom
)
=>
self
.add_predicate_atom
(
atom
),
}
}
fn
add_predicate_atom
(
&
mut
self
,
atom
:
ty
::
PredicateAtom
<
'_
>
)
{
match
atom
{
ty
::
PredicateAtom
::
Trait
(
trait_pred
,
_
constness
)
=>
{
self
.add_substs
(
trait_pred
.trait_ref.substs
);
}
ty
::
PredicateAtom
::
RegionOutlives
(
ty
::
OutlivesPredicate
(
a
,
b
))
=>
{
self
.add_region
(
a
);
self
.add_region
(
b
);
}
ty
::
PredicateAtom
::
TypeOutlives
(
ty
::
OutlivesPredicate
(
ty
,
region
))
=>
{
self
.add_ty
(
ty
);
self
.add_region
(
region
);
}
ty
::
PredicateAtom
::
Subtype
(
ty
::
SubtypePredicate
{
a_is_expected
:
_
,
a
,
b
})
=>
{
self
.add_ty
(
a
);
self
.add_ty
(
b
);
}
ty
::
PredicateAtom
::
Projection
(
ty
::
ProjectionPredicate
{
projection_ty
,
ty
})
=>
{
self
.add_projection_ty
(
projection_ty
);
self
.add_ty
(
ty
);
}
ty
::
PredicateAtom
::
WellFormed
(
arg
)
=>
{
self
.add_substs
(
slice
::
from_ref
(
&
arg
));
}
ty
::
PredicateAtom
::
ObjectSafe
(
_
def_id
)
=>
{}
ty
::
PredicateAtom
::
ClosureKind
(
_
def_id
,
substs
,
_
kind
)
=>
{
self
.add_substs
(
substs
);
}
ty
::
PredicateAtom
::
ConstEvaluatable
(
_
def_id
,
substs
)
=>
{
self
.add_substs
(
substs
);
}
ty
::
PredicateAtom
::
ConstEquate
(
expected
,
found
)
=>
{
self
.add_const
(
expected
);
self
.add_const
(
found
);
}
}
}
...
...
src/librustc_middle/ty/mod.rs
浏览文件 @
cd9743b4
...
...
@@ -1053,8 +1053,9 @@ pub fn kind(self) -> &'tcx PredicateKind<'tcx> {
///
/// Note that this method panics in case this predicate has unbound variables.
pub
fn
skip_binders
(
self
)
->
PredicateAtom
<
'tcx
>
{
// TODO no_escaping_vars
match
self
.kind
()
{
&
PredicateKind
::
ForAll
(
binder
)
=>
binder
.skip_binder
()
.skip_binders
()
,
&
PredicateKind
::
ForAll
(
binder
)
=>
binder
.skip_binder
(),
&
ty
::
PredicateKind
::
Atom
(
atom
)
=>
atom
,
}
}
...
...
@@ -1066,33 +1067,17 @@ pub fn skip_binders(self) -> PredicateAtom<'tcx> {
/// to end up at the wrong binding level.
pub
fn
skip_binders_unchecked
(
self
)
->
PredicateAtom
<
'tcx
>
{
match
self
.kind
()
{
&
PredicateKind
::
ForAll
(
binder
)
=>
binder
.skip_binder
()
.skip_binders
()
,
&
PredicateKind
::
ForAll
(
binder
)
=>
binder
.skip_binder
(),
&
ty
::
PredicateKind
::
Atom
(
atom
)
=>
atom
,
}
}
pub
fn
bound_atom
(
self
,
tcx
:
TyCtxt
<
'tcx
>
)
->
Binder
<
PredicateAtom
<
'tcx
>>
{
match
self
.kind
()
{
&
PredicateKind
::
ForAll
(
binder
)
=>
binder
.map_bound
(|
inner
|
match
inner
.kind
()
{
ty
::
PredicateKind
::
ForAll
(
_
)
=>
bug!
(
"unexpect forall"
),
&
ty
::
PredicateKind
::
Atom
(
atom
)
=>
atom
,
}),
&
PredicateKind
::
ForAll
(
binder
)
=>
binder
,
&
ty
::
PredicateKind
::
Atom
(
atom
)
=>
Binder
::
wrap_nonbinding
(
tcx
,
atom
),
}
}
/// Wraps `self` with the given qualifier if this predicate has any unbound variables.
pub
fn
potentially_quantified
(
self
,
tcx
:
TyCtxt
<
'tcx
>
,
qualifier
:
impl
FnOnce
(
Binder
<
Predicate
<
'tcx
>>
)
->
PredicateKind
<
'tcx
>
,
)
->
Predicate
<
'tcx
>
{
if
self
.has_escaping_bound_vars
()
{
qualifier
(
Binder
::
bind
(
self
))
.to_predicate
(
tcx
)
}
else
{
self
}
}
}
impl
<
'a
,
'tcx
>
HashStable
<
StableHashingContext
<
'a
>>
for
Predicate
<
'tcx
>
{
...
...
@@ -1114,7 +1099,7 @@ fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHas
#[derive(HashStable,
TypeFoldable)]
pub
enum
PredicateKind
<
'tcx
>
{
/// `for<'a>: ...`
ForAll
(
Binder
<
Predicate
<
'tcx
>>
),
ForAll
(
Binder
<
Predicate
Atom
<
'tcx
>>
),
Atom
(
PredicateAtom
<
'tcx
>
),
}
...
...
@@ -1162,6 +1147,22 @@ pub enum PredicateAtom<'tcx> {
ConstEquate
(
&
'tcx
Const
<
'tcx
>
,
&
'tcx
Const
<
'tcx
>
),
}
impl
<
'tcx
>
PredicateAtom
<
'tcx
>
{
/// Wraps `self` with the given qualifier if this predicate has any unbound variables.
pub
fn
potentially_quantified
(
self
,
tcx
:
TyCtxt
<
'tcx
>
,
qualifier
:
impl
FnOnce
(
Binder
<
PredicateAtom
<
'tcx
>>
)
->
PredicateKind
<
'tcx
>
,
)
->
Predicate
<
'tcx
>
{
if
self
.has_escaping_bound_vars
()
{
qualifier
(
Binder
::
bind
(
self
))
}
else
{
PredicateKind
::
Atom
(
self
)
}
.to_predicate
(
tcx
)
}
}
/// The crate outlives map is computed during typeck and contains the
/// outlives of every item in the local crate. You should not use it
/// directly, because to do so will make your pass dependent on the
...
...
@@ -1249,11 +1250,7 @@ pub fn subst_supertrait(
let
substs
=
trait_ref
.skip_binder
()
.substs
;
let
pred
=
self
.skip_binders
();
let
new
=
pred
.subst
(
tcx
,
substs
);
if
new
!=
pred
{
new
.to_predicate
(
tcx
)
.potentially_quantified
(
tcx
,
PredicateKind
::
ForAll
)
}
else
{
self
}
if
new
!=
pred
{
new
.potentially_quantified
(
tcx
,
PredicateKind
::
ForAll
)
}
else
{
self
}
}
}
...
...
@@ -1381,6 +1378,7 @@ fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
impl
ToPredicate
<
'tcx
>
for
PredicateAtom
<
'tcx
>
{
#[inline(always)]
fn
to_predicate
(
&
self
,
tcx
:
TyCtxt
<
'tcx
>
)
->
Predicate
<
'tcx
>
{
debug_assert!
(
!
self
.has_escaping_bound_vars
(),
"excaping bound vars for {:?}"
,
self
);
tcx
.mk_predicate
(
ty
::
PredicateKind
::
Atom
(
*
self
))
}
}
...
...
@@ -1408,9 +1406,7 @@ fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
ty
::
PredicateAtom
::
Trait
(
pred
,
self
.constness
)
.to_predicate
(
tcx
)
}
else
{
ty
::
PredicateKind
::
ForAll
(
self
.value
.map_bound
(|
pred
|
{
ty
::
PredicateAtom
::
Trait
(
pred
,
self
.constness
)
.to_predicate
(
tcx
)
}),
self
.value
.map_bound
(|
pred
|
ty
::
PredicateAtom
::
Trait
(
pred
,
self
.constness
)),
)
.to_predicate
(
tcx
)
}
...
...
@@ -1423,9 +1419,7 @@ fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
PredicateAtom
::
RegionOutlives
(
outlives
)
.to_predicate
(
tcx
)
}
else
{
ty
::
PredicateKind
::
ForAll
(
self
.map_bound
(|
outlives
|
{
PredicateAtom
::
RegionOutlives
(
outlives
)
.to_predicate
(
tcx
)
}),
self
.map_bound
(|
outlives
|
PredicateAtom
::
RegionOutlives
(
outlives
)),
)
.to_predicate
(
tcx
)
}
...
...
@@ -1438,7 +1432,7 @@ fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
PredicateAtom
::
TypeOutlives
(
outlives
)
.to_predicate
(
tcx
)
}
else
{
ty
::
PredicateKind
::
ForAll
(
self
.map_bound
(|
outlives
|
PredicateAtom
::
TypeOutlives
(
outlives
)
.to_predicate
(
tcx
)
),
self
.map_bound
(|
outlives
|
PredicateAtom
::
TypeOutlives
(
outlives
)),
)
.to_predicate
(
tcx
)
}
...
...
@@ -1450,10 +1444,8 @@ fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
if
let
Some
(
proj
)
=
self
.no_bound_vars
()
{
PredicateAtom
::
Projection
(
proj
)
.to_predicate
(
tcx
)
}
else
{
ty
::
PredicateKind
::
ForAll
(
self
.map_bound
(|
proj
|
PredicateAtom
::
Projection
(
proj
)
.to_predicate
(
tcx
)),
)
.to_predicate
(
tcx
)
ty
::
PredicateKind
::
ForAll
(
self
.map_bound
(|
proj
|
PredicateAtom
::
Projection
(
proj
)))
.to_predicate
(
tcx
)
}
}
}
...
...
src/librustc_middle/ty/print/pretty.rs
浏览文件 @
cd9743b4
...
...
@@ -2013,43 +2013,45 @@ pub fn print_only_trait_path(self) -> ty::Binder<TraitRefPrintOnlyTraitPath<'tcx
ty
::
Predicate
<
'tcx
>
{
match
self
.kind
()
{
&
ty
::
PredicateKind
::
Atom
(
atom
)
=>
match
atom
{
ty
::
PredicateAtom
::
Trait
(
ref
data
,
constness
)
=>
{
if
let
hir
::
Constness
::
Const
=
constness
{
p!
(
write
(
"const "
));
}
p!
(
print
(
data
))
}
ty
::
PredicateAtom
::
Subtype
(
predicate
)
=>
p!
(
print
(
predicate
)),
ty
::
PredicateAtom
::
RegionOutlives
(
predicate
)
=>
p!
(
print
(
predicate
)),
ty
::
PredicateAtom
::
TypeOutlives
(
predicate
)
=>
p!
(
print
(
predicate
)),
ty
::
PredicateAtom
::
Projection
(
predicate
)
=>
p!
(
print
(
predicate
)),
ty
::
PredicateAtom
::
WellFormed
(
arg
)
=>
p!
(
print
(
arg
),
write
(
" well-formed"
)),
ty
::
PredicateAtom
::
ObjectSafe
(
trait_def_id
)
=>
{
p!
(
write
(
"the trait `"
),
print_def_path
(
trait_def_id
,
&
[]),
write
(
"` is object-safe"
))
}
ty
::
PredicateAtom
::
ClosureKind
(
closure_def_id
,
_
closure_substs
,
kind
)
=>
{
p!
(
write
(
"the closure `"
),
print_value_path
(
closure_def_id
,
&
[]),
write
(
"` implements the trait `{}`"
,
kind
))
}
ty
::
PredicateAtom
::
ConstEvaluatable
(
def
,
substs
)
=>
{
p!
(
write
(
"the constant `"
),
print_value_path
(
def
.did
,
substs
),
write
(
"` can be evaluated"
))
}
ty
::
PredicateAtom
::
ConstEquate
(
c1
,
c2
)
=>
{
p!
(
write
(
"the constant `"
),
print
(
c1
),
write
(
"` equals `"
),
print
(
c2
),
write
(
"`"
))
&
ty
::
PredicateKind
::
Atom
(
atom
)
=>
p!
(
print
(
atom
)),
ty
::
PredicateKind
::
ForAll
(
binder
)
=>
p!
(
print
(
binder
)),
}
}
ty
::
PredicateAtom
<
'tcx
>
{
match
*
self
{
ty
::
PredicateAtom
::
Trait
(
ref
data
,
constness
)
=>
{
if
let
hir
::
Constness
::
Const
=
constness
{
p!
(
write
(
"const "
));
}
}
ty
::
PredicateKind
::
ForAll
(
binder
)
=>
{
p!
(
print
(
binder
))
p!
(
print
(
data
))
}
ty
::
PredicateAtom
::
Subtype
(
predicate
)
=>
p!
(
print
(
predicate
)),
ty
::
PredicateAtom
::
RegionOutlives
(
predicate
)
=>
p!
(
print
(
predicate
)),
ty
::
PredicateAtom
::
TypeOutlives
(
predicate
)
=>
p!
(
print
(
predicate
)),
ty
::
PredicateAtom
::
Projection
(
predicate
)
=>
p!
(
print
(
predicate
)),
ty
::
PredicateAtom
::
WellFormed
(
arg
)
=>
p!
(
print
(
arg
),
write
(
" well-formed"
)),
ty
::
PredicateAtom
::
ObjectSafe
(
trait_def_id
)
=>
{
p!
(
write
(
"the trait `"
),
print_def_path
(
trait_def_id
,
&
[]),
write
(
"` is object-safe"
))
}
ty
::
PredicateAtom
::
ClosureKind
(
closure_def_id
,
_
closure_substs
,
kind
)
=>
{
p!
(
write
(
"the closure `"
),
print_value_path
(
closure_def_id
,
&
[]),
write
(
"` implements the trait `{}`"
,
kind
))
}
ty
::
PredicateAtom
::
ConstEvaluatable
(
def
,
substs
)
=>
{
p!
(
write
(
"the constant `"
),
print_value_path
(
def
.did
,
substs
),
write
(
"` can be evaluated"
))
}
ty
::
PredicateAtom
::
ConstEquate
(
c1
,
c2
)
=>
{
p!
(
write
(
"the constant `"
),
print
(
c1
),
write
(
"` equals `"
),
print
(
c2
),
write
(
"`"
))
}
}
}
...
...
src/librustc_trait_selection/traits/fulfill.rs
浏览文件 @
cd9743b4
...
...
@@ -6,6 +6,7 @@
use
rustc_infer
::
traits
::{
PolyTraitObligation
,
TraitEngine
,
TraitEngineExt
as
_
};
use
rustc_middle
::
mir
::
interpret
::
ErrorHandled
;
use
rustc_middle
::
ty
::
error
::
ExpectedFound
;
use
rustc_middle
::
ty
::
ToPredicate
;
use
rustc_middle
::
ty
::{
self
,
Binder
,
Const
,
Ty
,
TypeFoldable
};
use
std
::
marker
::
PhantomData
;
...
...
src/librustc_trait_selection/traits/wf.rs
浏览文件 @
cd9743b4
...
...
@@ -93,45 +93,40 @@ pub fn predicate_obligations<'a, 'tcx>(
)
->
Vec
<
traits
::
PredicateObligation
<
'tcx
>>
{
let
mut
wf
=
WfPredicates
{
infcx
,
param_env
,
body_id
,
span
,
out
:
vec!
[],
item
:
None
};
match
predicate
.kind
()
{
ty
::
PredicateKind
::
ForAll
(
binder
)
=>
{
// It's ok to skip the binder here because wf code is prepared for it
return
predicate_obligations
(
infcx
,
param_env
,
body_id
,
binder
.skip_binder
(),
span
);
// It's ok to skip the binder here because wf code is prepared for it
match
predicate
.skip_binders
()
{
ty
::
PredicateAtom
::
Trait
(
t
,
_
)
=>
{
wf
.compute_trait_ref
(
&
t
.trait_ref
,
Elaborate
::
None
);
}
&
ty
::
PredicateKind
::
Atom
(
atom
)
=>
match
atom
{
ty
::
PredicateAtom
::
Trait
(
t
,
_
)
=>
{
wf
.compute_trait_ref
(
&
t
.trait_ref
,
Elaborate
::
None
);
}
ty
::
PredicateAtom
::
RegionOutlives
(
..
)
=>
{}
ty
::
PredicateAtom
::
TypeOutlives
(
ty
::
OutlivesPredicate
(
ty
,
_
reg
))
=>
{
wf
.compute
(
ty
.into
());
}
ty
::
PredicateAtom
::
Projection
(
t
)
=>
{
wf
.compute_projection
(
t
.projection_ty
);
wf
.compute
(
t
.ty
.into
());
}
ty
::
PredicateAtom
::
WellFormed
(
arg
)
=>
{
wf
.compute
(
arg
);
}
ty
::
PredicateAtom
::
ObjectSafe
(
_
)
=>
{}
ty
::
PredicateAtom
::
ClosureKind
(
..
)
=>
{}
ty
::
PredicateAtom
::
Subtype
(
ty
::
SubtypePredicate
{
a
,
b
,
a_is_expected
:
_
})
=>
{
wf
.compute
(
a
.into
());
wf
.compute
(
b
.into
());
}
ty
::
PredicateAtom
::
ConstEvaluatable
(
def
,
substs
)
=>
{
let
obligations
=
wf
.nominal_obligations
(
def
.did
,
substs
);
wf
.out
.extend
(
obligations
);
ty
::
PredicateAtom
::
RegionOutlives
(
..
)
=>
{}
ty
::
PredicateAtom
::
TypeOutlives
(
ty
::
OutlivesPredicate
(
ty
,
_
reg
))
=>
{
wf
.compute
(
ty
.into
());
}
ty
::
PredicateAtom
::
Projection
(
t
)
=>
{
wf
.compute_projection
(
t
.projection_ty
);
wf
.compute
(
t
.ty
.into
());
}
ty
::
PredicateAtom
::
WellFormed
(
arg
)
=>
{
wf
.compute
(
arg
);
}
ty
::
PredicateAtom
::
ObjectSafe
(
_
)
=>
{}
ty
::
PredicateAtom
::
ClosureKind
(
..
)
=>
{}
ty
::
PredicateAtom
::
Subtype
(
ty
::
SubtypePredicate
{
a
,
b
,
a_is_expected
:
_
})
=>
{
wf
.compute
(
a
.into
());
wf
.compute
(
b
.into
());
}
ty
::
PredicateAtom
::
ConstEvaluatable
(
def
,
substs
)
=>
{
let
obligations
=
wf
.nominal_obligations
(
def
.did
,
substs
);
wf
.out
.extend
(
obligations
);
for
arg
in
substs
.iter
()
{
wf
.compute
(
arg
);
}
}
ty
::
PredicateAtom
::
ConstEquate
(
c1
,
c2
)
=>
{
wf
.compute
(
c1
.into
());
wf
.compute
(
c2
.into
());
for
arg
in
substs
.iter
()
{
wf
.compute
(
arg
);
}
},
}
ty
::
PredicateAtom
::
ConstEquate
(
c1
,
c2
)
=>
{
wf
.compute
(
c1
.into
());
wf
.compute
(
c2
.into
());
}
}
wf
.normalize
()
...
...
src/librustc_typeck/check/method/probe.rs
浏览文件 @
cd9743b4
...
...
@@ -798,24 +798,28 @@ fn assemble_inherent_candidates_from_param(&mut self, param_ty: ty::ParamTy) {
// FIXME: do we want to commit to this behavior for param bounds?
debug!
(
"assemble_inherent_candidates_from_param(param_ty={:?})"
,
param_ty
);
let
bounds
=
self
.param_env
.caller_bounds
()
.iter
()
.map
(
ty
::
Predicate
::
skip_binders
)
.filter_map
(|
predicate
|
match
predicate
{
ty
::
PredicateAtom
::
Trait
(
trait_predicate
,
_
)
=>
{
match
trait_predicate
.trait_ref
.self_ty
()
.kind
{
ty
::
Param
(
ref
p
)
if
*
p
==
param_ty
=>
Some
(
ty
::
Binder
::
bind
(
trait_predicate
.trait_ref
)),
_
=>
None
,
}
}
ty
::
PredicateAtom
::
Subtype
(
..
)
|
ty
::
PredicateAtom
::
Projection
(
..
)
|
ty
::
PredicateAtom
::
RegionOutlives
(
..
)
|
ty
::
PredicateAtom
::
WellFormed
(
..
)
|
ty
::
PredicateAtom
::
ObjectSafe
(
..
)
|
ty
::
PredicateAtom
::
ClosureKind
(
..
)
|
ty
::
PredicateAtom
::
TypeOutlives
(
..
)
|
ty
::
PredicateAtom
::
ConstEvaluatable
(
..
)
|
ty
::
PredicateAtom
::
ConstEquate
(
..
)
=>
None
,
});
let
bounds
=
self
.param_env
.caller_bounds
()
.iter
()
.map
(
ty
::
Predicate
::
skip_binders
)
.filter_map
(
|
predicate
|
match
predicate
{
ty
::
PredicateAtom
::
Trait
(
trait_predicate
,
_
)
=>
{
match
trait_predicate
.trait_ref
.self_ty
()
.kind
{
ty
::
Param
(
ref
p
)
if
*
p
==
param_ty
=>
{
Some
(
ty
::
Binder
::
bind
(
trait_predicate
.trait_ref
))
}
_
=>
None
,
}
}
ty
::
PredicateAtom
::
Subtype
(
..
)
|
ty
::
PredicateAtom
::
Projection
(
..
)
|
ty
::
PredicateAtom
::
RegionOutlives
(
..
)
|
ty
::
PredicateAtom
::
WellFormed
(
..
)
|
ty
::
PredicateAtom
::
ObjectSafe
(
..
)
|
ty
::
PredicateAtom
::
ClosureKind
(
..
)
|
ty
::
PredicateAtom
::
TypeOutlives
(
..
)
|
ty
::
PredicateAtom
::
ConstEvaluatable
(
..
)
|
ty
::
PredicateAtom
::
ConstEquate
(
..
)
=>
None
,
},
);
self
.elaborate_bounds
(
bounds
,
|
this
,
poly_trait_ref
,
item
|
{
let
trait_ref
=
this
.erase_late_bound_regions
(
&
poly_trait_ref
);
...
...
src/librustc_typeck/check/mod.rs
浏览文件 @
cd9743b4
...
...
@@ -2939,9 +2939,7 @@ fn get_type_parameter_bounds(&self, _: Span, def_id: DefId) -> ty::GenericPredic
predicates
:
tcx
.arena
.alloc_from_iter
(
self
.param_env
.caller_bounds
()
.iter
()
.filter_map
(|
predicate
|
{
match
predicate
.skip_binders
()
{
ty
::
PredicateAtom
::
Trait
(
data
,
_
)
if
data
.self_ty
()
.is_param
(
index
)
=>
{
ty
::
PredicateAtom
::
Trait
(
data
,
_
)
if
data
.self_ty
()
.is_param
(
index
)
=>
{
// HACK(eddyb) should get the original `Span`.
let
span
=
tcx
.def_span
(
def_id
);
Some
((
predicate
,
span
))
...
...
@@ -5373,7 +5371,6 @@ fn suggest_missing_await(
projection_ty
,
ty
:
expected
,
})
.to_predicate
(
self
.tcx
)
.potentially_quantified
(
self
.tcx
,
ty
::
PredicateKind
::
ForAll
);
let
obligation
=
traits
::
Obligation
::
new
(
self
.misc
(
sp
),
self
.param_env
,
predicate
);
...
...
src/librustc_typeck/collect.rs
浏览文件 @
cd9743b4
...
...
@@ -1961,7 +1961,6 @@ fn extend<I: IntoIterator<Item = (ty::Predicate<'tcx>, Span)>>(&mut self, iter:
let
region
=
AstConv
::
ast_region_to_region
(
&
icx
,
lifetime
,
None
);
predicates
.push
((
ty
::
PredicateAtom
::
TypeOutlives
(
ty
::
OutlivesPredicate
(
ty
,
region
))
.to_predicate
(
tcx
)
.potentially_quantified
(
tcx
,
ty
::
PredicateKind
::
ForAll
),
lifetime
.span
,
))
...
...
@@ -1979,8 +1978,7 @@ fn extend<I: IntoIterator<Item = (ty::Predicate<'tcx>, Span)>>(&mut self, iter:
}
_
=>
bug!
(),
};
let
pred
=
ty
::
PredicateAtom
::
RegionOutlives
(
ty
::
OutlivesPredicate
(
r1
,
r2
))
.to_predicate
(
icx
.tcx
);
let
pred
=
ty
::
PredicateAtom
::
RegionOutlives
(
ty
::
OutlivesPredicate
(
r1
,
r2
));
(
pred
.potentially_quantified
(
icx
.tcx
,
ty
::
PredicateKind
::
ForAll
),
span
)
}))
...
...
@@ -2111,7 +2109,6 @@ fn predicates_from_bound<'tcx>(
hir
::
GenericBound
::
Outlives
(
ref
lifetime
)
=>
{
let
region
=
astconv
.ast_region_to_region
(
lifetime
,
None
);
let
pred
=
ty
::
PredicateAtom
::
TypeOutlives
(
ty
::
OutlivesPredicate
(
param_ty
,
region
))
.to_predicate
(
astconv
.tcx
())
.potentially_quantified
(
astconv
.tcx
(),
ty
::
PredicateKind
::
ForAll
);
vec!
[(
pred
,
lifetime
.span
)]
}
...
...
src/librustc_typeck/outlives/mod.rs
浏览文件 @
cd9743b4
...
...
@@ -3,7 +3,7 @@
use
rustc_hir
::
def_id
::{
CrateNum
,
DefId
,
LOCAL_CRATE
};
use
rustc_middle
::
ty
::
query
::
Providers
;
use
rustc_middle
::
ty
::
subst
::
GenericArgKind
;
use
rustc_middle
::
ty
::{
self
,
CratePredicatesMap
,
T
oPredicate
,
T
yCtxt
};
use
rustc_middle
::
ty
::{
self
,
CratePredicatesMap
,
TyCtxt
};
use
rustc_span
::
symbol
::
sym
;
use
rustc_span
::
Span
;
...
...
@@ -90,7 +90,6 @@ fn inferred_outlives_crate(tcx: TyCtxt<'_>, crate_num: CrateNum) -> CratePredica
match
kind1
.unpack
()
{
GenericArgKind
::
Type
(
ty1
)
=>
Some
((
ty
::
PredicateAtom
::
TypeOutlives
(
ty
::
OutlivesPredicate
(
ty1
,
region2
))
.to_predicate
(
tcx
)
.potentially_quantified
(
tcx
,
ty
::
PredicateKind
::
ForAll
),
span
,
)),
...
...
@@ -98,7 +97,6 @@ fn inferred_outlives_crate(tcx: TyCtxt<'_>, crate_num: CrateNum) -> CratePredica
ty
::
PredicateAtom
::
RegionOutlives
(
ty
::
OutlivesPredicate
(
region1
,
region2
,
))
.to_predicate
(
tcx
)
.potentially_quantified
(
tcx
,
ty
::
PredicateKind
::
ForAll
),
span
,
)),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录