Skip to content

Commit b493b00

Browse files
Move tests back to using AsyncFn
1 parent d0273a7 commit b493b00

37 files changed

+62
-60
lines changed

compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
794794
closure_def_id,
795795
found_kind,
796796
expected_kind,
797-
"async ",
797+
"Async",
798798
);
799799
self.note_obligation_cause(&mut err, &obligation);
800800
self.point_at_returns_when_relevant(&mut err, &obligation);

tests/coverage/async_closure.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//@ aux-build: executor.rs
55
extern crate executor;
66

7-
async fn call_once(f: impl async FnOnce()) {
7+
async fn call_once(f: impl AsyncFnOnce()) {
88
f().await;
99
}
1010

tests/ui/async-await/async-closures/async-fn-mut-for-async-fn.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ fn main() {
1010
block_on::block_on(async {
1111
let x = async || {};
1212

13-
async fn needs_async_fn_mut(mut x: impl async FnMut()) {
13+
async fn needs_async_fn_mut(mut x: impl AsyncFnMut()) {
1414
x().await;
1515
}
1616
needs_async_fn_mut(x).await;

tests/ui/async-await/async-closures/async-fn-once-for-async-fn.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ extern crate block_on;
88

99
fn main() {
1010
block_on::block_on(async {
11-
async fn needs_async_fn_once(x: impl async FnOnce()) {
11+
async fn needs_async_fn_once(x: impl AsyncFnOnce()) {
1212
x().await;
1313
}
1414

tests/ui/async-await/async-closures/auxiliary/foreign.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
#![feature(async_closure)]
44

5-
pub fn closure() -> impl async Fn() {
5+
pub fn closure() -> impl AsyncFn() {
66
async || { /* Don't really need to do anything here. */ }
77
}

tests/ui/async-await/async-closures/body-check-on-non-fnmut.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ extern crate block_on;
1111

1212
async fn empty() {}
1313

14-
pub async fn call_once<F: async FnOnce()>(f: F) {
14+
pub async fn call_once<F: AsyncFnOnce()>(f: F) {
1515
f().await;
1616
}
1717

tests/ui/async-await/async-closures/box-deref-in-debuginfo.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ impl Trait for (i32,) {
1616
}
1717
}
1818

19-
async fn call_once(f: impl async FnOnce()) {
19+
async fn call_once(f: impl AsyncFnOnce()) {
2020
f().await;
2121
}
2222

tests/ui/async-await/async-closures/brand.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ struct S;
1313
struct B<'b>(PhantomData<&'b mut &'b mut ()>);
1414

1515
impl S {
16-
async fn q<F: async Fn(B<'_>)>(self, f: F) {
16+
async fn q<F: AsyncFn(B<'_>)>(self, f: F) {
1717
f(B(PhantomData)).await;
1818
}
1919
}

tests/ui/async-await/async-closures/captures.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ fn main() {
1313
block_on::block_on(async_main());
1414
}
1515

16-
async fn call<T>(f: &impl async Fn() -> T) -> T {
16+
async fn call<T>(f: &impl AsyncFn() -> T) -> T {
1717
f().await
1818
}
1919

20-
async fn call_once<T>(f: impl async FnOnce() -> T) -> T {
20+
async fn call_once<T>(f: impl AsyncFnOnce() -> T) -> T {
2121
f().await
2222
}
2323

@@ -80,7 +80,7 @@ async fn async_main() {
8080
call_once(c).await;
8181
}
8282

83-
fn force_fnonce<T>(f: impl async FnOnce() -> T) -> impl async FnOnce() -> T {
83+
fn force_fnonce<T>(f: impl AsyncFnOnce() -> T) -> impl AsyncFnOnce() -> T {
8484
f
8585
}
8686

tests/ui/async-await/async-closures/clone-closure.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
extern crate block_on;
99

10-
async fn for_each(f: impl async FnOnce(&str) + Clone) {
10+
async fn for_each(f: impl AsyncFnOnce(&str) + Clone) {
1111
f.clone()("world").await;
1212
f.clone()("world2").await;
1313
}

tests/ui/async-await/async-closures/constrained-but-no-upvars-yet.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66

77
#![feature(async_closure)]
88

9-
fn constrain<T: async FnOnce()>(t: T) -> T {
9+
fn constrain<T: AsyncFnOnce()>(t: T) -> T {
1010
t
1111
}
1212

1313
fn call_once<T>(f: impl FnOnce() -> T) -> T {
1414
f()
1515
}
1616

17-
async fn async_call_once<T>(f: impl async FnOnce() -> T) -> T {
17+
async fn async_call_once<T>(f: impl AsyncFnOnce() -> T) -> T {
1818
f().await
1919
}
2020

tests/ui/async-await/async-closures/debuginfo-by-move-body.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
extern crate block_on;
99

10-
async fn call_once(f: impl async FnOnce()) {
10+
async fn call_once(f: impl AsyncFnOnce()) {
1111
f().await;
1212
}
1313

tests/ui/async-await/async-closures/drop.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ impl Drop for DropMe {
1616
}
1717
}
1818

19-
async fn call_once(f: impl async FnOnce()) {
19+
async fn call_once(f: impl AsyncFnOnce()) {
2020
println!("before call");
2121
let fut = Box::pin(f());
2222
println!("after call");

tests/ui/async-await/async-closures/fn-exception-target-features.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use std::future::Future;
1010
#[target_feature(enable = "sse2")]
1111
fn target_feature() -> Pin<Box<dyn Future<Output = ()> + 'static>> { todo!() }
1212

13-
fn test(f: impl async Fn()) {}
13+
fn test(f: impl AsyncFn()) {}
1414

1515
fn main() {
1616
test(target_feature); //~ ERROR the trait bound

tests/ui/async-await/async-closures/fn-exception-target-features.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ LL | test(target_feature);
99
note: required by a bound in `test`
1010
--> $DIR/fn-exception-target-features.rs:13:17
1111
|
12-
LL | fn test(f: impl async Fn()) {}
13-
| ^^^^^^^^^^ required by this bound in `test`
12+
LL | fn test(f: impl AsyncFn()) {}
13+
| ^^^^^^^^^ required by this bound in `test`
1414

1515
error: aborting due to 1 previous error
1616

tests/ui/async-await/async-closures/fn-exception.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ unsafe extern "C" {
1313
pub safe fn abi() -> Pin<Box<dyn Future<Output = ()> + 'static>>;
1414
}
1515

16-
fn test(f: impl async Fn()) {}
16+
fn test(f: impl AsyncFn()) {}
1717

1818
fn main() {
1919
test(unsafety); //~ ERROR the trait bound

tests/ui/async-await/async-closures/fn-exception.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ LL | test(unsafety);
99
note: required by a bound in `test`
1010
--> $DIR/fn-exception.rs:16:17
1111
|
12-
LL | fn test(f: impl async Fn()) {}
13-
| ^^^^^^^^^^ required by this bound in `test`
12+
LL | fn test(f: impl AsyncFn()) {}
13+
| ^^^^^^^^^ required by this bound in `test`
1414

1515
error[E0277]: the trait bound `extern "C" fn() -> Pin<Box<(dyn Future<Output = ()> + 'static)>> {abi}: AsyncFn<()>` is not satisfied
1616
--> $DIR/fn-exception.rs:20:10
@@ -23,8 +23,8 @@ LL | test(abi);
2323
note: required by a bound in `test`
2424
--> $DIR/fn-exception.rs:16:17
2525
|
26-
LL | fn test(f: impl async Fn()) {}
27-
| ^^^^^^^^^^ required by this bound in `test`
26+
LL | fn test(f: impl AsyncFn()) {}
27+
| ^^^^^^^^^ required by this bound in `test`
2828

2929
error: aborting due to 2 previous errors
3030

tests/ui/async-await/async-closures/force-move-due-to-inferred-kind.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
extern crate block_on;
88

9-
fn force_fnonce<T: async FnOnce()>(t: T) -> T { t }
9+
fn force_fnonce<T: AsyncFnOnce()>(t: T) -> T { t }
1010

1111
fn main() {
1212
block_on::block_on(async {

tests/ui/async-await/async-closures/foreign.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ extern crate foreign;
1212

1313
struct NoCopy;
1414

15-
async fn call_once(f: impl async FnOnce()) {
15+
async fn call_once(f: impl AsyncFnOnce()) {
1616
f().await;
1717
}
1818

tests/ui/async-await/async-closures/implements-fnmut.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//@ build-pass
22
//@ edition: 2021
33

4-
// Demonstrates that an async closure may implement `FnMut` (not just `async FnMut`!)
4+
// Demonstrates that an async closure may implement `FnMut` (not just `AsyncFnMut`!)
55
// if it has no self-borrows. In this case, `&Ty` is not borrowed from the closure env,
66
// since it's fine to reborrow it with its original lifetime. See the doc comment on
77
// `should_reborrow_from_env_of_parent_coroutine_closure` for more detail for when we

tests/ui/async-await/async-closures/inline-body.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub fn block_on<T>(fut: impl Future<Output = T>) -> T {
2424
}
2525
}
2626

27-
async fn call_once<T>(f: impl async FnOnce() -> T) -> T {
27+
async fn call_once<T>(f: impl AsyncFnOnce() -> T) -> T {
2828
f().await
2929
}
3030

tests/ui/async-await/async-closures/mangle.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ use std::future::Future;
1313
use std::pin::pin;
1414
use std::task::*;
1515

16-
async fn call_mut(f: &mut impl async FnMut()) {
16+
async fn call_mut(f: &mut impl AsyncFnMut()) {
1717
f().await;
1818
}
1919

20-
async fn call_once(f: impl async FnOnce()) {
20+
async fn call_once(f: impl AsyncFnOnce()) {
2121
f().await;
2222
}
2323

tests/ui/async-await/async-closures/moro-example.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ impl<'scope, 'env: 'scope> Scope<'scope, 'env> {
2222

2323
fn scope_with_closure<'env, B>(_body: B) -> BoxFuture<'env, ()>
2424
where
25-
for<'scope> B: async FnOnce(&'scope Scope<'scope, 'env>),
25+
for<'scope> B: AsyncFnOnce(&'scope Scope<'scope, 'env>),
2626
{
2727
todo!()
2828
}

tests/ui/async-await/async-closures/move-is-async-fn.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ fn main() {
1919
is_static(&c);
2020

2121
// Check that `<{async fn} as AsyncFnOnce>::CallOnceFuture` owns its captures.
22-
fn call_once<F: async FnOnce()>(f: F) -> F::CallOnceFuture { f() }
22+
fn call_once<F: AsyncFnOnce()>(f: F) -> F::CallOnceFuture { f() }
2323
is_static(&call_once(c));
2424
});
2525
}

tests/ui/async-await/async-closures/mut-ref-reborrow.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
extern crate block_on;
1111

12-
async fn call_once(f: impl async FnOnce()) { f().await; }
12+
async fn call_once(f: impl AsyncFnOnce()) { f().await; }
1313

1414
pub async fn async_closure(x: &mut i32) {
1515
let c = async move || {

tests/ui/async-await/async-closures/no-borrow-from-env.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
fn outlives<'a>(_: impl Sized + 'a) {}
77

8-
async fn call_once(f: impl async FnOnce()) {
8+
async fn call_once(f: impl AsyncFnOnce()) {
99
f().await;
1010
}
1111

tests/ui/async-await/async-closures/non-copy-arg-does-not-force-inner-move.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
extern crate block_on;
88

9-
fn wrapper(f: impl Fn(String)) -> impl async Fn(String) {
9+
fn wrapper(f: impl Fn(String)) -> impl AsyncFn(String) {
1010
async move |s| f(s)
1111
}
1212

tests/ui/async-await/async-closures/overlapping-projs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
extern crate block_on;
99

10-
async fn call_once(f: impl async FnOnce()) {
10+
async fn call_once(f: impl AsyncFnOnce()) {
1111
f().await;
1212
}
1313

tests/ui/async-await/async-closures/precise-captures.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//@ revisions: call call_once force_once
66

77
// call - Call the closure regularly.
8-
// call_once - Call the closure w/ `async FnOnce`, so exercising the by_move shim.
8+
// call_once - Call the closure w/ `AsyncFnOnce`, so exercising the by_move shim.
99
// force_once - Force the closure mode to `FnOnce`, so exercising what was fixed
1010
// in <https://github.com/rust-lang/rust/pull/123350>.
1111

@@ -20,7 +20,7 @@ macro_rules! call {
2020
}
2121

2222
#[cfg(call_once)]
23-
async fn call_once(f: impl async FnOnce()) {
23+
async fn call_once(f: impl AsyncFnOnce()) {
2424
f().await
2525
}
2626

@@ -35,7 +35,7 @@ macro_rules! guidance {
3535
}
3636

3737
#[cfg(force_once)]
38-
fn infer_fnonce(c: impl async FnOnce()) -> impl async FnOnce() { c }
38+
fn infer_fnonce(c: impl AsyncFnOnce()) -> impl AsyncFnOnce() { c }
3939

4040
#[cfg(force_once)]
4141
macro_rules! guidance {

tests/ui/async-await/async-closures/refd.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ struct NoCopy;
1010

1111
fn main() {
1212
block_on::block_on(async {
13-
async fn call_once(x: impl async Fn()) { x().await }
13+
async fn call_once(x: impl AsyncFn()) { x().await }
1414

15-
// check that `&{async-closure}` implements `async Fn`.
15+
// check that `&{async-closure}` implements `AsyncFn`.
1616
call_once(&async || {}).await;
1717

18-
// check that `&{closure}` implements `async Fn`.
18+
// check that `&{closure}` implements `AsyncFn`.
1919
call_once(&|| async {}).await;
2020

21-
// check that `&fndef` implements `async Fn`.
21+
// check that `&fndef` implements `AsyncFn`.
2222
async fn foo() {}
2323
call_once(&foo).await;
2424
});

tests/ui/async-await/async-closures/signature-deduction.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#![feature(async_closure)]
55

6-
async fn foo(x: impl async Fn(&str) -> &str) {}
6+
async fn foo(x: impl AsyncFn(&str) -> &str) {}
77

88
fn main() {
99
foo(async |x| x);

tests/ui/async-await/async-closures/without-precise-captures-we-are-powerless.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
fn outlives<'a>(_: impl Sized + 'a) {}
1010

11-
async fn call_once(f: impl async FnOnce()) {
11+
async fn call_once(f: impl AsyncFnOnce()) {
1212
f().await;
1313
}
1414

tests/ui/async-await/async-closures/wrong-fn-kind.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#![feature(async_closure)]
44

5-
fn needs_async_fn(_: impl async Fn()) {}
5+
fn needs_async_fn(_: impl AsyncFn()) {}
66

77
fn a() {
88
let mut x = 1;
@@ -15,7 +15,7 @@ fn a() {
1515
fn b() {
1616
let x = String::new();
1717
needs_async_fn(move || async move {
18-
//~^ ERROR expected a closure that implements the `async Fn` trait, but this closure only implements `async FnOnce`
18+
//~^ ERROR expected a closure that implements the `AsyncFn` trait, but this closure only implements `AsyncFnOnce`
1919
println!("{x}");
2020
});
2121
}

0 commit comments

Comments
 (0)