diff --git a/tests/run-pass-fullmir/async-fn.rs b/tests/run-pass-fullmir/async-fn.rs new file mode 100644 index 000000000000..7c32b026df67 --- /dev/null +++ b/tests/run-pass-fullmir/async-fn.rs @@ -0,0 +1,35 @@ +#![feature( + async_await, + await_macro, + futures_api, + pin, +)] + +use std::{future::Future, pin::Pin, task::Poll}; + +// See if we can run a basic `async fn` +pub async fn foo(x: &u32, y: u32) -> u32 { + let y = &y; + let z = 9; + let z = &z; + let y = await!(async { *y + *z }); + let a = 10; + let a = &a; + *x + y + *a +} + +fn main() { + use std::{sync::Arc, task::{Wake, local_waker}}; + + struct NoWake; + impl Wake for NoWake { + fn wake(_arc_self: &Arc) { + panic!(); + } + } + + let lw = unsafe { local_waker(Arc::new(NoWake)) }; + let x = 5; + let mut fut = foo(&x, 7); + assert_eq!(unsafe { Pin::new_unchecked(&mut fut) }.poll(&lw), Poll::Ready(31)); +}