]> git.lizzy.rs Git - rust.git/blob - tests/ui/impl-trait/hidden-type-is-opaque-2.rs
Rollup merge of #106097 - mejrs:mir_build2, r=oli-obk
[rust.git] / tests / ui / impl-trait / hidden-type-is-opaque-2.rs
1 // This doesn't work, because we don't flow information from opaque types
2 // into function arguments via the function's generic parameters
3 // FIXME(oli-obk): make `expected_inputs_for_expected_output` support this
4
5 #![feature(type_alias_impl_trait)]
6
7 fn reify_as() -> Thunk<impl FnOnce(Continuation) -> Continuation> {
8     Thunk::new(|mut cont| {
9         cont.reify_as(); //~ ERROR type annotations needed
10         cont
11     })
12 }
13
14 type Tait = impl FnOnce(Continuation) -> Continuation;
15
16 fn reify_as_tait() -> Thunk<Tait> {
17     Thunk::new(|mut cont| {
18         cont.reify_as(); //~ ERROR type annotations needed
19         cont
20     })
21 }
22
23 #[must_use]
24 struct Thunk<F>(F);
25
26 impl<F> Thunk<F> {
27     fn new(f: F) -> Self
28     where
29         F: ContFn,
30     {
31         Thunk(f)
32     }
33 }
34
35 trait ContFn {}
36
37 impl<F: FnOnce(Continuation) -> Continuation> ContFn for F {}
38
39 struct Continuation;
40
41 impl Continuation {
42     fn reify_as(&mut self) {}
43 }
44
45 fn main() {}