]> git.proxmox.com Git - rustc.git/blobdiff - src/test/ui/async-await/async-await.rs
Update unsuspicious file list
[rustc.git] / src / test / ui / async-await / async-await.rs
index 0eae1467fbfa0e6e80bdb617297d584f6ffc532b..9cabf16f8bba98e432fdea8c1ba2e10fdccf1dce 100644 (file)
@@ -1,9 +1,13 @@
 // run-pass
 
-// edition:2018
-// aux-build:arc_wake.rs
+// revisions: default nomiropt thirunsafeck
+//[nomiropt]compile-flags: -Z mir-opt-level=0
+//[thirunsafeck]compile-flags: -Zthir-unsafeck
+
+#![allow(unused)]
 
-#![feature(async_await)]
+// edition: 2018
+// aux-build:arc_wake.rs
 
 extern crate arc_wake;
 
@@ -70,12 +74,7 @@ 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)
-}
+// see async-closure.rs for async_closure + async_closure_in_unsafe_block
 
 async fn async_fn(x: u8) -> u8 {
     wake_and_yield_once().await;
@@ -104,12 +103,10 @@ fn async_fn_with_impl_future_named_lifetime<'a>(x: &'a u8) -> impl Future<Output
     }
 }
 
-/* FIXME(cramertj) support when `existential type T<'a, 'b>:;` works
 async fn async_fn_multiple_args(x: &u8, _y: &u8) -> u8 {
-    await!(wake_and_yield_once());
+    wake_and_yield_once().await;
     *x
 }
-*/
 
 async fn async_fn_multiple_args_named_lifetime<'a>(x: &'a u8, _y: &'a u8) -> u8 {
     wake_and_yield_once().await;
@@ -127,6 +124,18 @@ async unsafe fn unsafe_async_fn(x: u8) -> u8 {
     x
 }
 
+unsafe fn unsafe_fn(x: u8) -> u8 {
+    x
+}
+
+fn async_block_in_unsafe_block(x: u8) -> impl Future<Output = u8> {
+    unsafe {
+        async move {
+            unsafe_fn(unsafe_async_fn(x).await)
+        }
+    }
+}
+
 struct Foo;
 
 trait Bar {
@@ -180,10 +189,10 @@ fn main() {
     test! {
         async_block,
         async_nonmove_block,
-        async_closure,
         async_fn,
         generic_async_fn,
         async_fn_with_internal_borrow,
+        async_block_in_unsafe_block,
         Foo::async_assoc_item,
         |x| {
             async move {