From f1308783b4a7e613d60bddfa0f5474363c198289 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Tue, 6 Feb 2024 17:41:48 +0000 Subject: [PATCH] Make async closures test use async bound modifier --- .../async-closures/async-fn-mut-for-async-fn.rs | 6 ++---- .../async-closures/async-fn-once-for-async-fn.rs | 6 ++---- .../async-await/async-closures/auxiliary/block-on.rs | 2 +- tests/ui/async-await/async-closures/brand.rs | 5 ++--- tests/ui/async-await/async-closures/drop.rs | 6 ++---- tests/ui/async-await/async-closures/mangle.rs | 7 +++---- tests/ui/async-await/async-closures/wrong-fn-kind.rs | 8 +++----- .../ui/async-await/async-closures/wrong-fn-kind.stderr | 10 +++++----- 8 files changed, 20 insertions(+), 30 deletions(-) diff --git a/tests/ui/async-await/async-closures/async-fn-mut-for-async-fn.rs b/tests/ui/async-await/async-closures/async-fn-mut-for-async-fn.rs index 8d7dc6a276b90..f73b43dd152f0 100644 --- a/tests/ui/async-await/async-closures/async-fn-mut-for-async-fn.rs +++ b/tests/ui/async-await/async-closures/async-fn-mut-for-async-fn.rs @@ -5,17 +5,15 @@ // FIXME(async_closures): When `fn_sig_for_fn_abi` is fixed, remove this. // ignore-pass (test emits codegen-time warnings) -#![feature(async_closure, async_fn_traits)] +#![feature(async_closure)] extern crate block_on; -use std::ops::AsyncFnMut; - fn main() { block_on::block_on(async { let x = async || {}; - async fn needs_async_fn_mut(mut x: impl AsyncFnMut()) { + async fn needs_async_fn_mut(mut x: impl async FnMut()) { x().await; } needs_async_fn_mut(x).await; diff --git a/tests/ui/async-await/async-closures/async-fn-once-for-async-fn.rs b/tests/ui/async-await/async-closures/async-fn-once-for-async-fn.rs index 4afc43fe6bd92..0ba323a71cd13 100644 --- a/tests/ui/async-await/async-closures/async-fn-once-for-async-fn.rs +++ b/tests/ui/async-await/async-closures/async-fn-once-for-async-fn.rs @@ -5,17 +5,15 @@ // FIXME(async_closures): When `fn_sig_for_fn_abi` is fixed, remove this. // ignore-pass (test emits codegen-time warnings) -#![feature(async_closure, async_fn_traits)] +#![feature(async_closure)] extern crate block_on; -use std::ops::AsyncFnOnce; - fn main() { block_on::block_on(async { let x = async || {}; - async fn needs_async_fn_once(x: impl AsyncFnOnce()) { + async fn needs_async_fn_once(x: impl async FnOnce()) { x().await; } needs_async_fn_once(x).await; diff --git a/tests/ui/async-await/async-closures/auxiliary/block-on.rs b/tests/ui/async-await/async-closures/auxiliary/block-on.rs index 3c27548b865a7..902e033cfe711 100644 --- a/tests/ui/async-await/async-closures/auxiliary/block-on.rs +++ b/tests/ui/async-await/async-closures/auxiliary/block-on.rs @@ -1,6 +1,6 @@ // edition: 2021 -#![feature(async_closure, noop_waker, async_fn_traits)] +#![feature(async_closure, noop_waker)] use std::future::Future; use std::pin::pin; diff --git a/tests/ui/async-await/async-closures/brand.rs b/tests/ui/async-await/async-closures/brand.rs index 3bda7737bb406..26d2ed5a6ef65 100644 --- a/tests/ui/async-await/async-closures/brand.rs +++ b/tests/ui/async-await/async-closures/brand.rs @@ -2,19 +2,18 @@ // edition:2021 // build-pass -#![feature(async_closure, async_fn_traits)] +#![feature(async_closure)] extern crate block_on; use std::future::Future; use std::marker::PhantomData; -use std::ops::AsyncFn; struct S; struct B<'b>(PhantomData<&'b mut &'b mut ()>); impl S { - async fn q)>(self, f: F) { + async fn q)>(self, f: F) { f(B(PhantomData)).await; } } diff --git a/tests/ui/async-await/async-closures/drop.rs b/tests/ui/async-await/async-closures/drop.rs index 1b7f2f8a600d0..a243d20774d27 100644 --- a/tests/ui/async-await/async-closures/drop.rs +++ b/tests/ui/async-await/async-closures/drop.rs @@ -3,13 +3,11 @@ // run-pass // check-run-results -#![feature(async_closure, async_fn_traits)] +#![feature(async_closure)] #![allow(unused)] extern crate block_on; -use std::ops::AsyncFnOnce; - struct DropMe(i32); impl Drop for DropMe { @@ -18,7 +16,7 @@ impl Drop for DropMe { } } -async fn call_once(f: impl AsyncFnOnce()) { +async fn call_once(f: impl async FnOnce()) { println!("before call"); let fut = Box::pin(f()); println!("after call"); diff --git a/tests/ui/async-await/async-closures/mangle.rs b/tests/ui/async-await/async-closures/mangle.rs index 98065c3c71109..9d231d551765e 100644 --- a/tests/ui/async-await/async-closures/mangle.rs +++ b/tests/ui/async-await/async-closures/mangle.rs @@ -8,20 +8,19 @@ // FIXME(async_closures): When `fn_sig_for_fn_abi` is fixed, remove this. // ignore-pass (test emits codegen-time warnings) -#![feature(async_closure, noop_waker, async_fn_traits)] +#![feature(async_closure, noop_waker)] extern crate block_on; use std::future::Future; -use std::ops::{AsyncFnMut, AsyncFnOnce}; use std::pin::pin; use std::task::*; -async fn call_mut(f: &mut impl AsyncFnMut()) { +async fn call_mut(f: &mut impl async FnMut()) { f().await; } -async fn call_once(f: impl AsyncFnOnce()) { +async fn call_once(f: impl async FnOnce()) { f().await; } diff --git a/tests/ui/async-await/async-closures/wrong-fn-kind.rs b/tests/ui/async-await/async-closures/wrong-fn-kind.rs index 248288325319e..f86cee3e0709e 100644 --- a/tests/ui/async-await/async-closures/wrong-fn-kind.rs +++ b/tests/ui/async-await/async-closures/wrong-fn-kind.rs @@ -2,17 +2,15 @@ // FIXME(async_closures): This needs a better error message! -#![feature(async_closure, async_fn_traits)] - -use std::ops::AsyncFn; +#![feature(async_closure)] fn main() { - fn needs_async_fn(_: impl AsyncFn()) {} + fn needs_async_fn(_: impl async Fn()) {} let mut x = 1; needs_async_fn(async || { //~^ ERROR i16: ops::async_function::internal_implementation_detail::AsyncFnKindHelper - // FIXME: Should say "closure is AsyncFnMut but it needs AsyncFn" or sth. + // FIXME: Should say "closure is `async FnMut` but it needs `async Fn`" or sth. x += 1; }); } diff --git a/tests/ui/async-await/async-closures/wrong-fn-kind.stderr b/tests/ui/async-await/async-closures/wrong-fn-kind.stderr index ef95e6a211c74..4ef8484cc34cd 100644 --- a/tests/ui/async-await/async-closures/wrong-fn-kind.stderr +++ b/tests/ui/async-await/async-closures/wrong-fn-kind.stderr @@ -1,21 +1,21 @@ error[E0277]: the trait bound `i16: ops::async_function::internal_implementation_detail::AsyncFnKindHelper` is not satisfied - --> $DIR/wrong-fn-kind.rs:13:20 + --> $DIR/wrong-fn-kind.rs:11:20 | LL | needs_async_fn(async || { | _____--------------_^ | | | | | required by a bound introduced by this call LL | | -LL | | // FIXME: Should say "closure is AsyncFnMut but it needs AsyncFn" or sth. +LL | | // FIXME: Should say "closure is `async FnMut` but it needs `async Fn`" or sth. LL | | x += 1; LL | | }); | |_____^ the trait `ops::async_function::internal_implementation_detail::AsyncFnKindHelper` is not implemented for `i16` | note: required by a bound in `needs_async_fn` - --> $DIR/wrong-fn-kind.rs:10:31 + --> $DIR/wrong-fn-kind.rs:8:31 | -LL | fn needs_async_fn(_: impl AsyncFn()) {} - | ^^^^^^^^^ required by this bound in `needs_async_fn` +LL | fn needs_async_fn(_: impl async Fn()) {} + | ^^^^^^^^^^ required by this bound in `needs_async_fn` error: aborting due to 1 previous error