Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
e853d6c5
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,发现更多精彩内容 >>
提交
e853d6c5
编写于
7月 08, 2018
作者:
C
csmoe
提交者:
scalexm
11月 13, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Implement `ProjectionEq-Normalize`
上级
5c9f7dcd
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
44 addition
and
1 deletion
+44
-1
src/librustc_traits/lowering/mod.rs
src/librustc_traits/lowering/mod.rs
+43
-1
src/test/ui/chalkify/lower_trait.stderr
src/test/ui/chalkify/lower_trait.stderr
+1
-0
未找到文件。
src/librustc_traits/lowering/mod.rs
浏览文件 @
e853d6c5
...
...
@@ -496,9 +496,51 @@ pub fn program_clauses_for_associated_type_def<'a, 'tcx>(
};
let
from_env_clause
=
Clause
::
ForAll
(
ty
::
Binder
::
bind
(
from_env_clause
));
// Rule ProjectionEq-Normalize
//
// ProjectionEq can succeed by normalizing:
// ```
// forall<Self, P1..Pn, Pn+1..Pm, U> {
// ProjectionEq(<Self as Trait<P1..Pn>>::AssocType<Pn+1..Pm> = U) :-
// Normalize(<Self as Trait<P1..Pn>>::AssocType<Pn+1..Pm> -> U)
// }
// ```
let
offset
=
tcx
.generics_of
(
trait_id
)
.params
.iter
()
.map
(|
p
|
p
.index
)
.max
()
.unwrap_or
(
0
);
// Add a new type param after the existing ones (`U` in the comment above).
let
ty_var
=
ty
::
Bound
(
ty
::
BoundTy
::
new
(
ty
::
INNERMOST
,
ty
::
BoundVar
::
from_u32
(
offset
+
1
))
);
// `ProjectionEq(<Self as Trait<P1..Pn>>::AssocType<Pn+1..Pm> = U)`
let
projection
=
ty
::
ProjectionPredicate
{
projection_ty
,
ty
:
tcx
.mk_ty
(
ty_var
),
};
// `Normalize(<A0 as Trait<A1..An>>::AssocType<Pn+1..Pm> -> U)`
let
hypothesis
=
tcx
.mk_goal
(
DomainGoal
::
Normalize
(
projection
)
.into_goal
()
);
// ProjectionEq(<Self as Trait<P1..Pn>>::AssocType<Pn+1..Pm> = U) :-
// Normalize(<Self as Trait<P1..Pn>>::AssocType<Pn+1..Pm> -> U)
let
normalize_clause
=
ProgramClause
{
goal
:
DomainGoal
::
Holds
(
WhereClause
::
ProjectionEq
(
projection
)),
hypotheses
:
tcx
.mk_goals
(
iter
::
once
(
hypothesis
)),
category
:
ProgramClauseCategory
::
Other
,
};
let
normalize_clause
=
Clause
::
ForAll
(
ty
::
Binder
::
bind
(
normalize_clause
));
let
clauses
=
iter
::
once
(
projection_eq_clause
)
.chain
(
iter
::
once
(
wf_clause
))
.chain
(
iter
::
once
(
from_env_clause
));
.chain
(
iter
::
once
(
from_env_clause
))
.chain
(
iter
::
once
(
normalize_clause
));
tcx
.mk_clauses
(
clauses
)
}
...
...
src/test/ui/chalkify/lower_trait.stderr
浏览文件 @
e853d6c5
...
...
@@ -15,6 +15,7 @@ error: program clause dump
LL | #[rustc_dump_program_clauses] //~ ERROR program clause dump
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: forall<Self, S, T, ^3> { ProjectionEq(<Self as Foo<S, T>>::Assoc == ^3) :- Normalize(<Self as Foo<S, T>>::Assoc -> ^3). }
= note: forall<Self, S, T> { FromEnv(Self: Foo<S, T>) :- FromEnv(Unnormalized(<Self as Foo<S, T>>::Assoc)). }
= note: forall<Self, S, T> { ProjectionEq(<Self as Foo<S, T>>::Assoc == Unnormalized(<Self as Foo<S, T>>::Assoc)). }
= note: forall<Self, S, T> { WellFormed(Unnormalized(<Self as Foo<S, T>>::Assoc)) :- Implemented(Self: Foo<S, T>). }
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录