Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
663002f2
R
Rust
项目概览
int
/
Rust
11 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
663002f2
编写于
10月 06, 2018
作者:
S
scalexm
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Pass around interned refs to goals and not goals
上级
25a75a4d
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
88 addition
and
73 deletion
+88
-73
src/Cargo.lock
src/Cargo.lock
+4
-4
src/librustc/Cargo.toml
src/librustc/Cargo.toml
+1
-1
src/librustc/ich/impls_ty.rs
src/librustc/ich/impls_ty.rs
+1
-1
src/librustc/traits/mod.rs
src/librustc/traits/mod.rs
+12
-10
src/librustc/traits/structural_impls.rs
src/librustc/traits/structural_impls.rs
+17
-17
src/librustc/ty/context.rs
src/librustc/ty/context.rs
+17
-12
src/librustc_traits/Cargo.toml
src/librustc_traits/Cargo.toml
+1
-1
src/librustc_traits/chalk_context.rs
src/librustc_traits/chalk_context.rs
+21
-20
src/librustc_traits/lowering.rs
src/librustc_traits/lowering.rs
+14
-7
未找到文件。
src/Cargo.lock
浏览文件 @
663002f2
...
...
@@ -270,7 +270,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "chalk-engine"
version = "0.
7
.0"
version = "0.
8
.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"chalk-macros 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
...
...
@@ -1898,7 +1898,7 @@ dependencies = [
"backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"chalk-engine 0.
7
.0 (registry+https://github.com/rust-lang/crates.io-index)",
"chalk-engine 0.
8
.0 (registry+https://github.com/rust-lang/crates.io-index)",
"flate2 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"fmt_macros 0.0.0",
"graphviz 0.0.0",
...
...
@@ -2434,7 +2434,7 @@ name = "rustc_traits"
version = "0.0.0"
dependencies = [
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"chalk-engine 0.
7
.0 (registry+https://github.com/rust-lang/crates.io-index)",
"chalk-engine 0.
8
.0 (registry+https://github.com/rust-lang/crates.io-index)",
"graphviz 0.0.0",
"log 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc 0.0.0",
...
...
@@ -3195,7 +3195,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum cargo_metadata 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2d6809b327f87369e6f3651efd2c5a96c49847a3ed2559477ecba79014751ee1"
"checksum cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)" = "f159dfd43363c4d08055a07703eb7a3406b0dac4d0584d96965a3262db3c9d16"
"checksum cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0c4e7bb64a8ebb0d856483e1e682ea3422f883c5f5615a90d51a2c82fe87fdd3"
"checksum chalk-engine 0.
7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "25ce2f28f55ed544a2a3756b7acf41dd7d6f27acffb2086439950925506af7d0
"
"checksum chalk-engine 0.
8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6749eb72e7d4355d944a99f15fbaea701b978c18c5e184a025fcde942b0c9779
"
"checksum chalk-macros 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "295635afd6853aa9f20baeb7f0204862440c0fe994c5a253d5f479dac41d047e"
"checksum chrono 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6962c635d530328acc53ac6a955e83093fedc91c5809dfac1fa60fa470830a37"
"checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e"
...
...
src/librustc/Cargo.toml
浏览文件 @
663002f2
...
...
@@ -31,7 +31,7 @@ syntax_pos = { path = "../libsyntax_pos" }
backtrace
=
"0.3.3"
parking_lot
=
"0.6"
byteorder
=
{
version
=
"1.1"
,
features
=
["i128"]
}
chalk-engine
=
{
version
=
"0.
7
.0"
,
default-features
=
false
}
chalk-engine
=
{
version
=
"0.
8
.0"
,
default-features
=
false
}
rustc_fs_util
=
{
path
=
"../librustc_fs_util"
}
smallvec
=
{
version
=
"0.6.5"
,
features
=
["union"]
}
...
...
src/librustc/ich/impls_ty.rs
浏览文件 @
663002f2
...
...
@@ -1356,7 +1356,7 @@ impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for traits::Goal<'tcx> {
fn
hash_stable
<
W
:
StableHasherResult
>
(
&
self
,
hcx
:
&
mut
StableHashingContext
<
'a
>
,
hasher
:
&
mut
StableHasher
<
W
>
)
{
use
traits
::
Goal
::
*
;
use
traits
::
Goal
Kind
::
*
;
mem
::
discriminant
(
self
)
.hash_stable
(
hcx
,
hasher
);
match
self
{
...
...
src/librustc/traits/mod.rs
浏览文件 @
663002f2
...
...
@@ -318,31 +318,33 @@ pub enum QuantifierKind {
}
#[derive(Copy,
Clone,
PartialEq,
Eq,
Hash,
Debug)]
pub
enum
Goal
<
'tcx
>
{
Implies
(
Clauses
<
'tcx
>
,
&
'tcx
Goal
<
'tcx
>
),
And
(
&
'tcx
Goal
<
'tcx
>
,
&
'tcx
Goal
<
'tcx
>
),
Not
(
&
'tcx
Goal
<
'tcx
>
),
pub
enum
Goal
Kind
<
'tcx
>
{
Implies
(
Clauses
<
'tcx
>
,
Goal
<
'tcx
>
),
And
(
Goal
<
'tcx
>
,
Goal
<
'tcx
>
),
Not
(
Goal
<
'tcx
>
),
DomainGoal
(
DomainGoal
<
'tcx
>
),
Quantified
(
QuantifierKind
,
ty
::
Binder
<
&
'tcx
Goal
<
'tcx
>>
),
Quantified
(
QuantifierKind
,
ty
::
Binder
<
Goal
<
'tcx
>>
),
CannotProve
,
}
pub
type
Goal
<
'tcx
>
=
&
'tcx
GoalKind
<
'tcx
>
;
pub
type
Goals
<
'tcx
>
=
&
'tcx
List
<
Goal
<
'tcx
>>
;
impl
<
'tcx
>
DomainGoal
<
'tcx
>
{
pub
fn
into_goal
(
self
)
->
Goal
<
'tcx
>
{
Goal
::
DomainGoal
(
self
)
pub
fn
into_goal
(
self
)
->
Goal
Kind
<
'tcx
>
{
Goal
Kind
::
DomainGoal
(
self
)
}
}
impl
<
'tcx
>
Goal
<
'tcx
>
{
impl
<
'tcx
>
Goal
Kind
<
'tcx
>
{
pub
fn
from_poly_domain_goal
<
'a
>
(
domain_goal
:
PolyDomainGoal
<
'tcx
>
,
tcx
:
TyCtxt
<
'a
,
'tcx
,
'tcx
>
,
)
->
Goal
<
'tcx
>
{
)
->
Goal
Kind
<
'tcx
>
{
match
domain_goal
.no_late_bound_regions
()
{
Some
(
p
)
=>
p
.into_goal
(),
None
=>
Goal
::
Quantified
(
None
=>
Goal
Kind
::
Quantified
(
QuantifierKind
::
Universal
,
domain_goal
.map_bound
(|
p
|
tcx
.mk_goal
(
p
.into_goal
()))
),
...
...
src/librustc/traits/structural_impls.rs
浏览文件 @
663002f2
...
...
@@ -469,7 +469,7 @@ fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
impl
<
'tcx
>
fmt
::
Display
for
traits
::
Goal
<
'tcx
>
{
fn
fmt
(
&
self
,
fmt
:
&
mut
fmt
::
Formatter
<
'_
>
)
->
fmt
::
Result
{
use
traits
::
Goal
::
*
;
use
traits
::
Goal
Kind
::
*
;
match
self
{
Implies
(
hypotheses
,
goal
)
=>
{
...
...
@@ -598,25 +598,25 @@ impl<'a, 'tcx> Lift<'tcx> for traits::DomainGoal<'a> {
}
EnumTypeFoldableImpl!
{
impl
<
'tcx
>
TypeFoldable
<
'tcx
>
for
traits
::
Goal
<
'tcx
>
{
(
traits
::
Goal
::
Implies
)(
hypotheses
,
goal
),
(
traits
::
Goal
::
And
)(
goal1
,
goal2
),
(
traits
::
Goal
::
Not
)(
goal
),
(
traits
::
Goal
::
DomainGoal
)(
domain_goal
),
(
traits
::
Goal
::
Quantified
)(
qkind
,
goal
),
(
traits
::
Goal
::
CannotProve
),
impl
<
'tcx
>
TypeFoldable
<
'tcx
>
for
traits
::
Goal
Kind
<
'tcx
>
{
(
traits
::
Goal
Kind
::
Implies
)(
hypotheses
,
goal
),
(
traits
::
Goal
Kind
::
And
)(
goal1
,
goal2
),
(
traits
::
Goal
Kind
::
Not
)(
goal
),
(
traits
::
Goal
Kind
::
DomainGoal
)(
domain_goal
),
(
traits
::
Goal
Kind
::
Quantified
)(
qkind
,
goal
),
(
traits
::
Goal
Kind
::
CannotProve
),
}
}
EnumLiftImpl!
{
impl
<
'a
,
'tcx
>
Lift
<
'tcx
>
for
traits
::
Goal
<
'a
>
{
type
Lifted
=
traits
::
Goal
<
'tcx
>
;
(
traits
::
Goal
::
Implies
)(
hypotheses
,
goal
),
(
traits
::
Goal
::
And
)(
goal1
,
goal2
),
(
traits
::
Goal
::
Not
)(
goal
),
(
traits
::
Goal
::
DomainGoal
)(
domain_goal
),
(
traits
::
Goal
::
Quantified
)(
kind
,
goal
),
(
traits
::
Goal
::
CannotProve
),
impl
<
'a
,
'tcx
>
Lift
<
'tcx
>
for
traits
::
Goal
Kind
<
'a
>
{
type
Lifted
=
traits
::
Goal
Kind
<
'tcx
>
;
(
traits
::
Goal
Kind
::
Implies
)(
hypotheses
,
goal
),
(
traits
::
Goal
Kind
::
And
)(
goal1
,
goal2
),
(
traits
::
Goal
Kind
::
Not
)(
goal
),
(
traits
::
Goal
Kind
::
DomainGoal
)(
domain_goal
),
(
traits
::
Goal
Kind
::
Quantified
)(
kind
,
goal
),
(
traits
::
Goal
Kind
::
CannotProve
),
}
}
...
...
@@ -633,7 +633,7 @@ fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
}
}
impl
<
'tcx
>
TypeFoldable
<
'tcx
>
for
&
'tcx
traits
::
Goal
<
'tcx
>
{
impl
<
'tcx
>
TypeFoldable
<
'tcx
>
for
traits
::
Goal
<
'tcx
>
{
fn
super_fold_with
<
'gcx
:
'tcx
,
F
:
TypeFolder
<
'gcx
,
'tcx
>>
(
&
self
,
folder
:
&
mut
F
)
->
Self
{
let
v
=
(
**
self
)
.fold_with
(
folder
);
folder
.tcx
()
.mk_goal
(
v
)
...
...
src/librustc/ty/context.rs
浏览文件 @
663002f2
...
...
@@ -36,7 +36,7 @@
use
ty
::
subst
::{
CanonicalSubsts
,
Kind
,
Substs
,
Subst
};
use
ty
::
ReprOptions
;
use
traits
;
use
traits
::{
Clause
,
Clauses
,
Goal
,
Goals
};
use
traits
::{
Clause
,
Clauses
,
Goal
Kind
,
Goal
,
Goals
};
use
ty
::{
self
,
Ty
,
TypeAndMut
};
use
ty
::{
TyS
,
TyKind
,
List
};
use
ty
::{
AdtKind
,
AdtDef
,
ClosureSubsts
,
GeneratorSubsts
,
Region
,
Const
};
...
...
@@ -143,7 +143,8 @@ pub struct CtxtInterners<'tcx> {
predicates
:
InternedSet
<
'tcx
,
List
<
Predicate
<
'tcx
>>>
,
const_
:
InternedSet
<
'tcx
,
Const
<
'tcx
>>
,
clauses
:
InternedSet
<
'tcx
,
List
<
Clause
<
'tcx
>>>
,
goals
:
InternedSet
<
'tcx
,
List
<
Goal
<
'tcx
>>>
,
goal
:
InternedSet
<
'tcx
,
GoalKind
<
'tcx
>>
,
goal_list
:
InternedSet
<
'tcx
,
List
<
Goal
<
'tcx
>>>
,
}
impl
<
'gcx
:
'tcx
,
'tcx
>
CtxtInterners
<
'tcx
>
{
...
...
@@ -159,7 +160,8 @@ fn new(arena: &'tcx SyncDroplessArena) -> CtxtInterners<'tcx> {
predicates
:
Default
::
default
(),
const_
:
Default
::
default
(),
clauses
:
Default
::
default
(),
goals
:
Default
::
default
(),
goal
:
Default
::
default
(),
goal_list
:
Default
::
default
(),
}
}
...
...
@@ -1731,9 +1733,9 @@ fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<Region<'t
}
}
impl
<
'a
,
'tcx
>
Lift
<
'tcx
>
for
&
'a
Goal
<
'a
>
{
type
Lifted
=
&
'tcx
Goal
<
'tcx
>
;
fn
lift_to_tcx
<
'b
,
'gcx
>
(
&
self
,
tcx
:
TyCtxt
<
'b
,
'gcx
,
'tcx
>
)
->
Option
<
&
'tcx
Goal
<
'tcx
>>
{
impl
<
'a
,
'tcx
>
Lift
<
'tcx
>
for
Goal
<
'a
>
{
type
Lifted
=
Goal
<
'tcx
>
;
fn
lift_to_tcx
<
'b
,
'gcx
>
(
&
self
,
tcx
:
TyCtxt
<
'b
,
'gcx
,
'tcx
>
)
->
Option
<
Goal
<
'tcx
>>
{
if
tcx
.interners.arena
.in_arena
(
*
self
as
*
const
_
)
{
return
Some
(
unsafe
{
mem
::
transmute
(
*
self
)
});
}
...
...
@@ -2304,6 +2306,12 @@ fn borrow<'a>(&'a self) -> &'a RegionKind {
}
}
impl
<
'tcx
:
'lcx
,
'lcx
>
Borrow
<
GoalKind
<
'lcx
>>
for
Interned
<
'tcx
,
GoalKind
<
'tcx
>>
{
fn
borrow
<
'a
>
(
&
'a
self
)
->
&
'a
GoalKind
<
'lcx
>
{
&
self
.0
}
}
impl
<
'tcx
:
'lcx
,
'lcx
>
Borrow
<
[
ExistentialPredicate
<
'lcx
>
]
>
for
Interned
<
'tcx
,
List
<
ExistentialPredicate
<
'tcx
>>>
{
fn
borrow
<
'a
>
(
&
'a
self
)
->
&
'a
[
ExistentialPredicate
<
'lcx
>
]
{
...
...
@@ -2419,7 +2427,8 @@ pub fn keep_local<'tcx, T: ty::TypeFoldable<'tcx>>(x: &T) -> bool {
direct_interners!
(
'tcx
,
region
:
mk_region
(|
r
:
&
RegionKind
|
r
.keep_in_local_tcx
())
->
RegionKind
,
const_
:
mk_const
(|
c
:
&
Const
<
'_
>
|
keep_local
(
&
c
.ty
)
||
keep_local
(
&
c
.val
))
->
Const
<
'tcx
>
const_
:
mk_const
(|
c
:
&
Const
<
'_
>
|
keep_local
(
&
c
.ty
)
||
keep_local
(
&
c
.val
))
->
Const
<
'tcx
>
,
goal
:
mk_goal
(|
c
:
&
GoalKind
<
'_
>
|
keep_local
(
c
))
->
GoalKind
<
'tcx
>
);
macro_rules!
slice_interners
{
...
...
@@ -2438,7 +2447,7 @@ pub fn keep_local<'tcx, T: ty::TypeFoldable<'tcx>>(x: &T) -> bool {
type_list
:
_
intern_type_list
(
Ty
),
substs
:
_
intern_substs
(
Kind
),
clauses
:
_
intern_clauses
(
Clause
),
goal
s
:
_
intern_goals
(
Goal
)
goal
_list
:
_
intern_goals
(
Goal
)
);
// This isn't a perfect fit: CanonicalVarInfo slices are always
...
...
@@ -2818,10 +2827,6 @@ pub fn mk_goals<I: InternAs<[Goal<'tcx>], Goals<'tcx>>>(self, iter: I) -> I::Out
iter
.intern_with
(|
xs
|
self
.intern_goals
(
xs
))
}
pub
fn
mk_goal
(
self
,
goal
:
Goal
<
'tcx
>
)
->
&
'tcx
Goal
<
'_
>
{
&
self
.intern_goals
(
&
[
goal
])[
0
]
}
pub
fn
lint_hir
<
S
:
Into
<
MultiSpan
>>
(
self
,
lint
:
&
'static
Lint
,
hir_id
:
HirId
,
...
...
src/librustc_traits/Cargo.toml
浏览文件 @
663002f2
...
...
@@ -16,5 +16,5 @@ rustc = { path = "../librustc" }
rustc_data_structures
=
{
path
=
"../librustc_data_structures"
}
syntax
=
{
path
=
"../libsyntax"
}
syntax_pos
=
{
path
=
"../libsyntax_pos"
}
chalk-engine
=
{
version
=
"0.
7
.0"
,
default-features
=
false
}
chalk-engine
=
{
version
=
"0.
8
.0"
,
default-features
=
false
}
smallvec
=
{
version
=
"0.6.5"
,
features
=
["union"]
}
src/librustc_traits/chalk_context.rs
浏览文件 @
663002f2
...
...
@@ -19,6 +19,7 @@
ExClauseFold
,
ExClauseLift
,
Goal
,
GoalKind
,
ProgramClause
,
QuantifierKind
};
...
...
@@ -92,7 +93,7 @@ impl context::Context for ChalkArenas<'tcx> {
type
DomainGoal
=
DomainGoal
<
'tcx
>
;
type
BindersGoal
=
ty
::
Binder
<
&
'tcx
Goal
<
'tcx
>>
;
type
BindersGoal
=
ty
::
Binder
<
Goal
<
'tcx
>>
;
type
Parameter
=
Kind
<
'tcx
>
;
...
...
@@ -102,14 +103,6 @@ impl context::Context for ChalkArenas<'tcx> {
type
UnificationResult
=
InferOk
<
'tcx
,
()
>
;
fn
into_goal
(
domain_goal
:
DomainGoal
<
'tcx
>
)
->
Goal
<
'tcx
>
{
Goal
::
DomainGoal
(
domain_goal
)
}
fn
cannot_prove
()
->
Goal
<
'tcx
>
{
Goal
::
CannotProve
}
fn
goal_in_environment
(
env
:
&
ty
::
ParamEnv
<
'tcx
>
,
goal
:
Goal
<
'tcx
>
,
...
...
@@ -251,15 +244,23 @@ fn map_subst_from_canonical(
impl
context
::
InferenceTable
<
ChalkArenas
<
'gcx
>
,
ChalkArenas
<
'tcx
>>
for
ChalkInferenceContext
<
'cx
,
'gcx
,
'tcx
>
{
fn
into_goal
(
&
self
,
domain_goal
:
DomainGoal
<
'tcx
>
)
->
Goal
<
'tcx
>
{
self
.infcx.tcx
.mk_goal
(
GoalKind
::
DomainGoal
(
domain_goal
))
}
fn
cannot_prove
(
&
self
)
->
Goal
<
'tcx
>
{
self
.infcx.tcx
.mk_goal
(
GoalKind
::
CannotProve
)
}
fn
into_hh_goal
(
&
mut
self
,
goal
:
Goal
<
'tcx
>
)
->
ChalkHhGoal
<
'tcx
>
{
match
goal
{
Goal
::
Implies
(
..
)
=>
panic!
(
"FIXME rust-lang-nursery/chalk#94"
),
Goal
::
And
(
left
,
right
)
=>
HhGoal
::
And
(
*
left
,
*
right
),
Goal
::
Not
(
subgoal
)
=>
HhGoal
::
Not
(
*
subgoal
),
Goal
::
DomainGoal
(
d
)
=>
HhGoal
::
DomainGoal
(
d
),
Goal
::
Quantified
(
QuantifierKind
::
Universal
,
binder
)
=>
HhGoal
::
ForAll
(
binder
),
Goal
::
Quantified
(
QuantifierKind
::
Existential
,
binder
)
=>
HhGoal
::
Exists
(
binder
),
Goal
::
CannotProve
=>
HhGoal
::
CannotProve
,
match
*
goal
{
Goal
Kind
::
Implies
(
..
)
=>
panic!
(
"FIXME rust-lang-nursery/chalk#94"
),
Goal
Kind
::
And
(
left
,
right
)
=>
HhGoal
::
And
(
left
,
right
),
Goal
Kind
::
Not
(
subgoal
)
=>
HhGoal
::
Not
(
subgoal
),
Goal
Kind
::
DomainGoal
(
d
)
=>
HhGoal
::
DomainGoal
(
d
),
Goal
Kind
::
Quantified
(
QuantifierKind
::
Universal
,
binder
)
=>
HhGoal
::
ForAll
(
binder
),
Goal
Kind
::
Quantified
(
QuantifierKind
::
Existential
,
binder
)
=>
HhGoal
::
Exists
(
binder
),
Goal
Kind
::
CannotProve
=>
HhGoal
::
CannotProve
,
}
}
...
...
@@ -363,21 +364,21 @@ fn program_clauses(
fn
instantiate_binders_universally
(
&
mut
self
,
_
arg
:
&
ty
::
Binder
<
&
'tcx
Goal
<
'tcx
>>
,
_
arg
:
&
ty
::
Binder
<
Goal
<
'tcx
>>
,
)
->
Goal
<
'tcx
>
{
panic!
(
"FIXME -- universal instantiation needs sgrif's branch"
)
}
fn
instantiate_binders_existentially
(
&
mut
self
,
arg
:
&
ty
::
Binder
<
&
'tcx
Goal
<
'tcx
>>
,
arg
:
&
ty
::
Binder
<
Goal
<
'tcx
>>
,
)
->
Goal
<
'tcx
>
{
let
(
value
,
_
map
)
=
self
.infcx
.replace_late_bound_regions_with_fresh_var
(
DUMMY_SP
,
LateBoundRegionConversionTime
::
HigherRankedType
,
arg
,
);
*
value
value
}
fn
debug_ex_clause
(
&
mut
self
,
value
:
&
'v
ChalkExClause
<
'tcx
>
)
->
Box
<
dyn
Debug
+
'v
>
{
...
...
src/librustc_traits/lowering.rs
浏览文件 @
663002f2
...
...
@@ -13,7 +13,14 @@
use
rustc
::
hir
::
map
::
definitions
::
DefPathData
;
use
rustc
::
hir
::{
self
,
ImplPolarity
};
use
rustc
::
traits
::{
Clause
,
Clauses
,
DomainGoal
,
FromEnv
,
Goal
,
PolyDomainGoal
,
ProgramClause
,
WellFormed
,
Clause
,
Clauses
,
DomainGoal
,
FromEnv
,
GoalKind
,
PolyDomainGoal
,
ProgramClause
,
WellFormed
,
WhereClause
,
};
use
rustc
::
ty
::
query
::
Providers
;
...
...
@@ -249,7 +256,7 @@ fn program_clauses_for_trait<'a, 'tcx>(
let
impl_trait
:
DomainGoal
=
trait_pred
.lower
();
// `FromEnv(Self: Trait<P1..Pn>)`
let
from_env_goal
=
impl_trait
.into_from_env_goal
()
.into_goal
(
);
let
from_env_goal
=
tcx
.mk_goal
(
impl_trait
.into_from_env_goal
()
.into_goal
()
);
let
hypotheses
=
tcx
.intern_goals
(
&
[
from_env_goal
]);
// `Implemented(Self: Trait<P1..Pn>) :- FromEnv(Self: Trait<P1..Pn>)`
...
...
@@ -308,7 +315,7 @@ fn program_clauses_for_trait<'a, 'tcx>(
let
wf_clause
=
ProgramClause
{
goal
:
DomainGoal
::
WellFormed
(
WellFormed
::
Trait
(
trait_pred
)),
hypotheses
:
tcx
.mk_goals
(
wf_conditions
.map
(|
wc
|
Goal
::
from_poly_domain_goal
(
wc
,
tcx
)),
wf_conditions
.map
(|
wc
|
tcx
.mk_goal
(
GoalKind
::
from_poly_domain_goal
(
wc
,
tcx
)
)),
),
};
let
wf_clause
=
iter
::
once
(
Clause
::
ForAll
(
ty
::
Binder
::
dummy
(
wf_clause
)));
...
...
@@ -352,7 +359,7 @@ fn program_clauses_for_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId
hypotheses
:
tcx
.mk_goals
(
where_clauses
.into_iter
()
.map
(|
wc
|
Goal
::
from_poly_domain_goal
(
wc
,
tcx
)),
.map
(|
wc
|
tcx
.mk_goal
(
GoalKind
::
from_poly_domain_goal
(
wc
,
tcx
)
)),
),
};
tcx
.intern_clauses
(
&
[
Clause
::
ForAll
(
ty
::
Binder
::
dummy
(
clause
))])
...
...
@@ -388,7 +395,7 @@ pub fn program_clauses_for_type_def<'a, 'tcx>(
where_clauses
.iter
()
.cloned
()
.map
(|
wc
|
Goal
::
from_poly_domain_goal
(
wc
,
tcx
)),
.map
(|
wc
|
tcx
.mk_goal
(
GoalKind
::
from_poly_domain_goal
(
wc
,
tcx
)
)),
),
};
...
...
@@ -404,7 +411,7 @@ pub fn program_clauses_for_type_def<'a, 'tcx>(
// ```
// `FromEnv(Ty<...>)`
let
from_env_goal
=
DomainGoal
::
FromEnv
(
FromEnv
::
Ty
(
ty
))
.into_goal
(
);
let
from_env_goal
=
tcx
.mk_goal
(
DomainGoal
::
FromEnv
(
FromEnv
::
Ty
(
ty
))
.into_goal
()
);
let
hypotheses
=
tcx
.intern_goals
(
&
[
from_env_goal
]);
// For each where clause `WC`:
...
...
@@ -482,7 +489,7 @@ pub fn program_clauses_for_associated_type_value<'a, 'tcx>(
hypotheses
:
tcx
.mk_goals
(
hypotheses
.into_iter
()
.map
(|
wc
|
Goal
::
from_poly_domain_goal
(
wc
,
tcx
)),
.map
(|
wc
|
tcx
.mk_goal
(
GoalKind
::
from_poly_domain_goal
(
wc
,
tcx
)
)),
),
};
tcx
.intern_clauses
(
&
[
Clause
::
ForAll
(
ty
::
Binder
::
dummy
(
clause
))])
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录