]> git.lizzy.rs Git - rust.git/blob - src/test/ui/async-await/issue-73137.rs
remove [async output] from impl Future
[rust.git] / src / test / ui / async-await / issue-73137.rs
1 // Regression test for <https://github.com/rust-lang/rust/issues/73137>
2
3 // run-pass
4 // edition:2018
5
6 #![allow(dead_code)]
7 use std::future::Future;
8 use std::task::{Waker, Wake, Context};
9 use std::sync::Arc;
10
11 struct DummyWaker;
12 impl Wake for DummyWaker {
13     fn wake(self: Arc<Self>) {}
14 }
15
16 struct Foo {
17     a: usize,
18     b: &'static u32,
19 }
20
21 #[inline(never)]
22 fn nop<T>(_: T) {}
23
24 fn main() {
25     let mut fut = Box::pin(async {
26         let action = Foo {
27             b: &42,
28             a: async { 0 }.await,
29         };
30
31         // An error in the generator transform caused `b` to be overwritten with `a` when `b` was
32         // borrowed.
33         nop(&action.b);
34         assert_ne!(0usize, unsafe { std::mem::transmute(action.b) });
35
36         async {}.await;
37     });
38     let waker = Waker::from(Arc::new(DummyWaker));
39     let mut cx = Context::from_waker(&waker);
40     let _ = fut.as_mut().poll(&mut cx);
41 }