Test that TAIT and RPIT are in sync

This commit is contained in:
Oli Scherer 2022-02-17 15:54:28 +00:00
parent 53c96ed528
commit 6596e9dfcf
4 changed files with 33 additions and 2 deletions

View file

@ -772,6 +772,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// Note: this check is pessimistic, as the inference type could be matched with something other
// than the opaque type, but then we need a new `TypeRelation` just for this specific case and
// can't re-use `sup` below.
// See src/test/ui/impl-trait/hidden-type-is-opaque.rs and
// src/test/ui/impl-trait/hidden-type-is-opaque-2.rs for examples that hit this path.
if formal_ret.has_infer_types() {
for ty in ret_ty.walk() {
if let ty::subst::GenericArgKind::Type(ty) = ty.unpack() {

View file

@ -2,6 +2,8 @@
// into function arguments via the function's generic parameters
// FIXME(oli-obk): make `expected_inputs_for_expected_output` support this
#![feature(type_alias_impl_trait)]
fn reify_as() -> Thunk<impl FnOnce(Continuation) -> Continuation> {
Thunk::new(|mut cont| { //~ ERROR type annotations needed
cont.reify_as();
@ -9,6 +11,15 @@ fn reify_as() -> Thunk<impl FnOnce(Continuation) -> Continuation> {
})
}
type Tait = impl FnOnce(Continuation) -> Continuation;
fn reify_as_tait() -> Thunk<Tait> {
Thunk::new(|mut cont| { //~ ERROR type annotations needed
cont.reify_as();
cont
})
}
#[must_use]
struct Thunk<F>(F);

View file

@ -1,11 +1,19 @@
error[E0282]: type annotations needed
--> $DIR/hidden-type-is-opaque-2.rs:6:17
--> $DIR/hidden-type-is-opaque-2.rs:8:17
|
LL | Thunk::new(|mut cont| {
| ^^^^^^^^ consider giving this closure parameter a type
|
= note: type must be known at this point
error: aborting due to previous error
error[E0282]: type annotations needed
--> $DIR/hidden-type-is-opaque-2.rs:17:17
|
LL | Thunk::new(|mut cont| {
| ^^^^^^^^ consider giving this closure parameter a type
|
= note: type must be known at this point
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0282`.

View file

@ -1,4 +1,5 @@
// check-pass
#![feature(type_alias_impl_trait)]
fn reify_as() -> Thunk<impl ContFn> {
Thunk::new(|mut cont| {
@ -7,6 +8,15 @@ fn reify_as() -> Thunk<impl ContFn> {
})
}
type Tait = impl ContFn;
fn reify_as_tait() -> Thunk<Tait> {
Thunk::new(|mut cont| {
cont.reify_as();
cont
})
}
#[must_use]
struct Thunk<F>(F);