]> git.lizzy.rs Git - rust.git/blob - src/test/ui/async-await/pin-needed-to-poll.rs
Rollup merge of #103570 - lukas-code:stabilize-ilog, r=scottmcm
[rust.git] / src / test / ui / async-await / pin-needed-to-poll.rs
1 use std::{
2     future::Future,
3     pin::Pin,
4     task::{Context, Poll},
5 };
6
7 struct Sleep;
8
9 impl Future for Sleep {
10     type Output = ();
11
12     fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
13         Poll::Ready(())
14     }
15 }
16
17 impl Drop for Sleep {
18     fn drop(&mut self) {}
19 }
20
21 fn sleep() -> Sleep {
22     Sleep
23 }
24
25
26 struct MyFuture {
27     sleep: Sleep,
28 }
29
30 impl MyFuture {
31     fn new() -> Self {
32         Self {
33             sleep: sleep(),
34         }
35     }
36 }
37
38 impl Future for MyFuture {
39     type Output = ();
40
41     fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
42         self.sleep.poll(cx)
43         //~^ ERROR no method named `poll` found for struct `Sleep` in the current scope
44     }
45 }
46
47 fn main() {}