Skip to content

Commit 7fe24a2

Browse files
committed
also add an async fn test
1 parent 8d6472a commit 7fe24a2

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

tests/run-pass-fullmir/async-fn.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#![feature(
2+
async_await,
3+
await_macro,
4+
futures_api,
5+
pin,
6+
)]
7+
8+
use std::{future::Future, pin::Pin, task::Poll};
9+
10+
// See if we can run a basic `async fn`
11+
pub async fn foo(x: &u32, y: u32) -> u32 {
12+
let y = &y;
13+
let z = 9;
14+
let z = &z;
15+
let y = await!(async { *y + *z });
16+
let a = 10;
17+
let a = &a;
18+
*x + y + *a
19+
}
20+
21+
fn main() {
22+
use std::{sync::Arc, task::{Wake, local_waker}};
23+
24+
struct NoWake;
25+
impl Wake for NoWake {
26+
fn wake(_arc_self: &Arc<Self>) {
27+
panic!();
28+
}
29+
}
30+
31+
let lw = unsafe { local_waker(Arc::new(NoWake)) };
32+
let x = 5;
33+
let mut fut = foo(&x, 7);
34+
assert_eq!(unsafe { Pin::new_unchecked(&mut fut) }.poll(&lw), Poll::Ready(31));
35+
}

0 commit comments

Comments
 (0)