diff options
| author | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-02-17 15:54:28 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-03-28 17:01:23 +0000 |
| commit | 6596e9dfcf15a76203ec12d64966f5b54eb7849c (patch) | |
| tree | e17acc71633d7072f96ae7957c63cdf7e49299ac | |
| parent | 53c96ed528257489f5537c69a33b27ffce6fee6f (diff) | |
| download | rust-6596e9dfcf15a76203ec12d64966f5b54eb7849c.tar.gz rust-6596e9dfcf15a76203ec12d64966f5b54eb7849c.zip | |
Test that TAIT and RPIT are in sync
| -rw-r--r-- | compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/impl-trait/hidden-type-is-opaque-2.rs | 11 | ||||
| -rw-r--r-- | src/test/ui/impl-trait/hidden-type-is-opaque-2.stderr | 12 | ||||
| -rw-r--r-- | src/test/ui/impl-trait/hidden-type-is-opaque.rs | 10 |
4 files changed, 33 insertions, 2 deletions
diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs b/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs index 97935efd4f0..bb3bfbb7dd1 100644 --- a/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs +++ b/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs @@ -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() { diff --git a/src/test/ui/impl-trait/hidden-type-is-opaque-2.rs b/src/test/ui/impl-trait/hidden-type-is-opaque-2.rs index 1b65685a6c0..7876add5aa6 100644 --- a/src/test/ui/impl-trait/hidden-type-is-opaque-2.rs +++ b/src/test/ui/impl-trait/hidden-type-is-opaque-2.rs @@ -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); diff --git a/src/test/ui/impl-trait/hidden-type-is-opaque-2.stderr b/src/test/ui/impl-trait/hidden-type-is-opaque-2.stderr index e538aaeb4c5..dcf1982312f 100644 --- a/src/test/ui/impl-trait/hidden-type-is-opaque-2.stderr +++ b/src/test/ui/impl-trait/hidden-type-is-opaque-2.stderr @@ -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`. diff --git a/src/test/ui/impl-trait/hidden-type-is-opaque.rs b/src/test/ui/impl-trait/hidden-type-is-opaque.rs index b302ae36ef4..72b4028d854 100644 --- a/src/test/ui/impl-trait/hidden-type-is-opaque.rs +++ b/src/test/ui/impl-trait/hidden-type-is-opaque.rs @@ -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); |
