]> git.proxmox.com Git - rustc.git/blame - tests/ui/async-await/in-trait/async-example-desugared-extra.rs
Update upstream source from tag 'upstream/1.70.0+dfsg1'
[rustc.git] / tests / ui / async-await / in-trait / async-example-desugared-extra.rs
CommitLineData
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
10use std::future::Future;
11use std::pin::Pin;
12use std::task::Poll;
13
14trait MyTrait {
15 async fn foo(&self) -> i32;
16}
17
18#[derive(Clone)]
19struct MyFuture(i32);
20
21impl 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
31impl 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
39fn main() {}