Skip to content

Commit 6596e9d

Browse files
committed
Test that TAIT and RPIT are in sync
1 parent 53c96ed commit 6596e9d

File tree

4 files changed

+33
-2
lines changed

4 files changed

+33
-2
lines changed

compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs

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

src/test/ui/impl-trait/hidden-type-is-opaque-2.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,24 @@
22
// into function arguments via the function's generic parameters
33
// FIXME(oli-obk): make `expected_inputs_for_expected_output` support this
44

5+
#![feature(type_alias_impl_trait)]
6+
57
fn reify_as() -> Thunk<impl FnOnce(Continuation) -> Continuation> {
68
Thunk::new(|mut cont| { //~ ERROR type annotations needed
79
cont.reify_as();
810
cont
911
})
1012
}
1113

14+
type Tait = impl FnOnce(Continuation) -> Continuation;
15+
16+
fn reify_as_tait() -> Thunk<Tait> {
17+
Thunk::new(|mut cont| { //~ ERROR type annotations needed
18+
cont.reify_as();
19+
cont
20+
})
21+
}
22+
1223
#[must_use]
1324
struct Thunk<F>(F);
1425

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
error[E0282]: type annotations needed
2-
--> $DIR/hidden-type-is-opaque-2.rs:6:17
2+
--> $DIR/hidden-type-is-opaque-2.rs:8:17
33
|
44
LL | Thunk::new(|mut cont| {
55
| ^^^^^^^^ consider giving this closure parameter a type
66
|
77
= note: type must be known at this point
88

9-
error: aborting due to previous error
9+
error[E0282]: type annotations needed
10+
--> $DIR/hidden-type-is-opaque-2.rs:17:17
11+
|
12+
LL | Thunk::new(|mut cont| {
13+
| ^^^^^^^^ consider giving this closure parameter a type
14+
|
15+
= note: type must be known at this point
16+
17+
error: aborting due to 2 previous errors
1018

1119
For more information about this error, try `rustc --explain E0282`.

src/test/ui/impl-trait/hidden-type-is-opaque.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// check-pass
2+
#![feature(type_alias_impl_trait)]
23

34
fn reify_as() -> Thunk<impl ContFn> {
45
Thunk::new(|mut cont| {
@@ -7,6 +8,15 @@ fn reify_as() -> Thunk<impl ContFn> {
78
})
89
}
910

11+
type Tait = impl ContFn;
12+
13+
fn reify_as_tait() -> Thunk<Tait> {
14+
Thunk::new(|mut cont| {
15+
cont.reify_as();
16+
cont
17+
})
18+
}
19+
1020
#[must_use]
1121
struct Thunk<F>(F);
1222

0 commit comments

Comments
 (0)