Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
c24f0635
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,发现更多精彩内容 >>
未验证
提交
c24f0635
编写于
5月 24, 2022
作者:
Y
Yuki Okushi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove a back-compat hack on lazy TAIT
上级
bd2e51a3
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
28 addition
and
31 deletion
+28
-31
compiler/rustc_infer/src/infer/opaque_types.rs
compiler/rustc_infer/src/infer/opaque_types.rs
+6
-8
compiler/rustc_trait_selection/src/traits/project.rs
compiler/rustc_trait_selection/src/traits/project.rs
+4
-17
src/test/ui/impl-trait/nested-return-type2.rs
src/test/ui/impl-trait/nested-return-type2.rs
+2
-6
src/test/ui/impl-trait/nested-return-type2.stderr
src/test/ui/impl-trait/nested-return-type2.stderr
+16
-0
未找到文件。
compiler/rustc_infer/src/infer/opaque_types.rs
浏览文件 @
c24f0635
...
...
@@ -39,21 +39,19 @@ pub struct OpaqueTypeDecl<'tcx> {
}
impl
<
'a
,
'tcx
>
InferCtxt
<
'a
,
'tcx
>
{
/// This is a backwards compatibility hack to prevent breaking changes from
/// lazy TAIT around RPIT handling.
pub
fn
replace_opaque_types_with_inference_vars
<
T
:
TypeFoldable
<
'tcx
>>
(
pub
fn
replace_opaque_types_with_inference_vars
(
&
self
,
value
:
T
,
ty
:
Ty
<
'tcx
>
,
body_id
:
HirId
,
span
:
Span
,
code
:
ObligationCauseCode
<
'tcx
>
,
param_env
:
ty
::
ParamEnv
<
'tcx
>
,
)
->
InferOk
<
'tcx
,
T
>
{
if
!
value
.has_opaque_types
()
{
return
InferOk
{
value
,
obligations
:
vec!
[]
};
)
->
InferOk
<
'tcx
,
T
y
<
'tcx
>
>
{
if
!
ty
.has_opaque_types
()
{
return
InferOk
{
value
:
ty
,
obligations
:
vec!
[]
};
}
let
mut
obligations
=
vec!
[];
let
value
=
value
.fold_with
(
&
mut
ty
::
fold
::
BottomUpFolder
{
let
value
=
ty
.fold_with
(
&
mut
ty
::
fold
::
BottomUpFolder
{
tcx
:
self
.tcx
,
lt_op
:
|
lt
|
lt
,
ct_op
:
|
ct
|
ct
,
...
...
compiler/rustc_trait_selection/src/traits/project.rs
浏览文件 @
c24f0635
...
...
@@ -28,7 +28,6 @@
use
rustc_hir
::
def_id
::
DefId
;
use
rustc_hir
::
lang_items
::
LangItem
;
use
rustc_infer
::
infer
::
resolve
::
OpportunisticRegionResolver
;
use
rustc_infer
::
traits
::
ObligationCauseCode
;
use
rustc_middle
::
traits
::
select
::
OverflowError
;
use
rustc_middle
::
ty
::
fold
::{
MaxUniverse
,
TypeFoldable
,
TypeFolder
,
TypeSuperFoldable
};
use
rustc_middle
::
ty
::
subst
::
Subst
;
...
...
@@ -252,22 +251,10 @@ fn project_and_unify_type<'cx, 'tcx>(
Err
(
InProgress
)
=>
return
ProjectAndUnifyResult
::
Recursive
,
};
debug!
(
?
normalized
,
?
obligations
,
"project_and_unify_type result"
);
let
actual
=
obligation
.predicate.term
;
// HACK: lazy TAIT would regress src/test/ui/impl-trait/nested-return-type2.rs, so we add
// a back-compat hack hat converts the RPITs into inference vars, just like they were before
// lazy TAIT.
// This does not affect TAITs in general, as tested in the nested-return-type-tait* tests.
let
InferOk
{
value
:
actual
,
obligations
:
new
}
=
selcx
.infcx
()
.replace_opaque_types_with_inference_vars
(
actual
,
obligation
.cause.body_id
,
obligation
.cause.span
,
ObligationCauseCode
::
MiscObligation
,
obligation
.param_env
,
);
obligations
.extend
(
new
);
match
infcx
.at
(
&
obligation
.cause
,
obligation
.param_env
)
.eq
(
normalized
,
actual
)
{
match
infcx
.at
(
&
obligation
.cause
,
obligation
.param_env
)
.eq
(
normalized
,
obligation
.predicate.term
)
{
Ok
(
InferOk
{
obligations
:
inferred_obligations
,
value
:
()
})
=>
{
obligations
.extend
(
inferred_obligations
);
ProjectAndUnifyResult
::
Holds
(
obligations
)
...
...
src/test/ui/impl-trait/nested-return-type2.rs
浏览文件 @
c24f0635
// check-pass
trait
Duh
{}
impl
Duh
for
i32
{}
...
...
@@ -20,11 +18,9 @@ impl<R: Duh, F: FnMut() -> R> Trait for F {
// the hidden type. We already have obligations registered on the inference
// var to make it uphold the `: Duh` bound on `Trait::Assoc`. The opaque
// type does not implement `Duh`, even if its hidden type does.
// Lazy TAIT would error out, but we inserted a hack to make it work again,
// keeping backwards compatibility.
fn
foo
()
->
impl
Trait
<
Assoc
=
impl
Send
>
{
//~^ ERROR `impl Send: Duh` is not satisfied
||
42
}
fn
main
()
{
}
fn
main
()
{}
src/test/ui/impl-trait/nested-return-type2.stderr
0 → 100644
浏览文件 @
c24f0635
error[E0277]: the trait bound `impl Send: Duh` is not satisfied
--> $DIR/nested-return-type2.rs:21:13
|
LL | fn foo() -> impl Trait<Assoc = impl Send> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Duh` is not implemented for `impl Send`
|
= help: the trait `Duh` is implemented for `i32`
note: required because of the requirements on the impl of `Trait` for `[closure@$DIR/nested-return-type2.rs:23:5: 23:10]`
--> $DIR/nested-return-type2.rs:12:31
|
LL | impl<R: Duh, F: FnMut() -> R> Trait for F {
| ^^^^^ ^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0277`.
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录