]> git.lizzy.rs Git - rust.git/commitdiff
fix async-fn test
authorRalf Jung <post@ralfj.de>
Fri, 15 Feb 2019 08:32:54 +0000 (09:32 +0100)
committerRalf Jung <post@ralfj.de>
Fri, 15 Feb 2019 08:35:55 +0000 (09:35 +0100)
tests/run-pass/async-fn.rs

index 9094a9fd3a6803ab6010a9f683ef94e791a76e7f..48f8fc1223c945ae9653cef65d199c131ea98488 100644 (file)
@@ -4,7 +4,8 @@
     futures_api,
 )]
 
-use std::{future::Future, pin::Pin, task::Poll};
+use std::{future::Future, pin::Pin, task::Poll, ptr};
+use std::task::{Waker, RawWaker, RawWakerVTable};
 
 // See if we can run a basic `async fn`
 pub async fn foo(x: &u32, y: u32) -> u32 {
@@ -17,18 +18,23 @@ pub async fn foo(x: &u32, y: u32) -> u32 {
     *x + y + *a
 }
 
-fn main() {
-    use std::{sync::Arc, task::{Wake, local_waker}};
+fn raw_waker_clone(_this: *const ()) -> RawWaker {
+    panic!("unimplemented");
+}
+fn raw_waker_wake(_this: *const ()) {
+    panic!("unimplemented");
+}
+fn raw_waker_drop(_this: *const ()) {}
 
-    struct NoWake;
-    impl Wake for NoWake {
-        fn wake(_arc_self: &Arc<Self>) {
-            panic!();
-        }
-    }
+static RAW_WAKER: RawWakerVTable = RawWakerVTable {
+    clone: raw_waker_clone,
+    wake: raw_waker_wake,
+    drop: raw_waker_drop,
+};
 
-    let lw = unsafe { local_waker(Arc::new(NoWake)) };
+fn main() {
     let x = 5;
     let mut fut = foo(&x, 7);
-    assert_eq!(unsafe { Pin::new_unchecked(&mut fut) }.poll(&lw), Poll::Ready(31));
+    let waker = unsafe { Waker::new_unchecked(RawWaker::new(ptr::null(), &RAW_WAKER)) };
+    assert_eq!(unsafe { Pin::new_unchecked(&mut fut) }.poll(&waker), Poll::Ready(31));
 }