]>
Commit | Line | Data |
---|---|---|
9c376795 FG |
1 | // check-pass |
2 | // edition: 2021 | |
353b0b11 FG |
3 | // [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty |
4 | // revisions: current next | |
9c376795 FG |
5 | |
6 | #![feature(async_fn_in_trait)] | |
7 | #![feature(return_position_impl_trait_in_trait)] | |
8 | #![allow(incomplete_features)] | |
9 | ||
10 | use std::future::Future; | |
11 | use std::pin::Pin; | |
12 | use std::task::Poll; | |
13 | ||
14 | trait MyTrait { | |
15 | async fn foo(&self) -> i32; | |
16 | } | |
17 | ||
18 | #[derive(Clone)] | |
19 | struct MyFuture(i32); | |
20 | ||
21 | impl Future for MyFuture { | |
22 | type Output = i32; | |
23 | fn poll( | |
24 | self: Pin<&mut Self>, | |
25 | _: &mut std::task::Context<'_>, | |
26 | ) -> Poll<<Self as Future>::Output> { | |
27 | Poll::Ready(self.0) | |
28 | } | |
29 | } | |
30 | ||
31 | impl MyTrait for i32 { | |
32 | // FIXME: this should eventually require `#[refine]` to compile, because it also provides | |
33 | // `Clone`. | |
34 | fn foo(&self) -> impl Future<Output = i32> + Clone { | |
35 | MyFuture(*self) | |
36 | } | |
37 | } | |
38 | ||
39 | fn main() {} |