]> git.lizzy.rs Git - rust.git/commitdiff
align async-await.rs and await-macro.rs with one another
authorDelan Azabani <delan@azabani.com>
Fri, 12 Jul 2019 03:04:41 +0000 (13:04 +1000)
committerDelan Azabani <delan@azabani.com>
Fri, 12 Jul 2019 03:23:30 +0000 (13:23 +1000)
src/test/ui/async-await/async-await.rs
src/test/ui/async-await/await-macro.rs

index 29622c9d030a3514aeb93ed46ee16097aec0e356..b9d82014bb9828d95bc688915c8184d7555d3dbb 100644 (file)
@@ -3,7 +3,7 @@
 // edition:2018
 // aux-build:arc_wake.rs
 
-#![feature(async_await)]
+#![feature(async_await, async_closure)]
 
 extern crate arc_wake;
 
@@ -70,6 +70,13 @@ fn async_nonmove_block(x: u8) -> impl Future<Output = u8> {
     }
 }
 
+fn async_closure(x: u8) -> impl Future<Output = u8> {
+    (async move |x: u8| -> u8 {
+        wake_and_yield_once().await;
+        x
+    })(x)
+}
+
 async fn async_fn(x: u8) -> u8 {
     wake_and_yield_once().await;
     x
@@ -173,6 +180,7 @@ macro_rules! test_with_borrow {
     test! {
         async_block,
         async_nonmove_block,
+        async_closure,
         async_fn,
         generic_async_fn,
         async_fn_with_internal_borrow,
index c37835d73e92be5b38148a95ab74ccf5b6b53cfe..7729cdf3cd93256eebd92b95229c5a0dc2c99a57 100644 (file)
@@ -134,11 +134,15 @@ fn foo() {}
 }
 
 impl Foo {
-    async fn async_method(x: u8) -> u8 {
+    async fn async_assoc_item(x: u8) -> u8 {
         unsafe {
             await!(unsafe_async_fn(x))
         }
     }
+
+    async unsafe fn async_unsafe_assoc_item(x: u8) -> u8 {
+        await!(unsafe_async_fn(x))
+    }
 }
 
 fn test_future_yields_once_then_returns<F, Fut>(f: F)
@@ -180,12 +184,17 @@ macro_rules! test_with_borrow {
         async_fn,
         generic_async_fn,
         async_fn_with_internal_borrow,
-        Foo::async_method,
+        Foo::async_assoc_item,
         |x| {
             async move {
                 unsafe { await!(unsafe_async_fn(x)) }
             }
         },
+        |x| {
+            async move {
+                unsafe { await!(Foo::async_unsafe_assoc_item(x)) }
+            }
+        },
     }
     test_with_borrow! {
         async_block_with_borrow_named_lifetime,