Skip to content

Commit d98a8a1

Browse files
authored
Rollup merge of #120713 - compiler-errors:async-bounds-on-tests, r=fmease
Make async closures test use async bound modifier Cosmetic change, separates the `AsyncFn` definitions from the tests.
2 parents 0ab3f01 + f130878 commit d98a8a1

File tree

8 files changed

+20
-30
lines changed

8 files changed

+20
-30
lines changed

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

+2-4
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,15 @@
55
// FIXME(async_closures): When `fn_sig_for_fn_abi` is fixed, remove this.
66
// ignore-pass (test emits codegen-time warnings)
77

8-
#![feature(async_closure, async_fn_traits)]
8+
#![feature(async_closure)]
99

1010
extern crate block_on;
1111

12-
use std::ops::AsyncFnMut;
13-
1412
fn main() {
1513
block_on::block_on(async {
1614
let x = async || {};
1715

18-
async fn needs_async_fn_mut(mut x: impl AsyncFnMut()) {
16+
async fn needs_async_fn_mut(mut x: impl async FnMut()) {
1917
x().await;
2018
}
2119
needs_async_fn_mut(x).await;

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

+2-4
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,15 @@
55
// FIXME(async_closures): When `fn_sig_for_fn_abi` is fixed, remove this.
66
// ignore-pass (test emits codegen-time warnings)
77

8-
#![feature(async_closure, async_fn_traits)]
8+
#![feature(async_closure)]
99

1010
extern crate block_on;
1111

12-
use std::ops::AsyncFnOnce;
13-
1412
fn main() {
1513
block_on::block_on(async {
1614
let x = async || {};
1715

18-
async fn needs_async_fn_once(x: impl AsyncFnOnce()) {
16+
async fn needs_async_fn_once(x: impl async FnOnce()) {
1917
x().await;
2018
}
2119
needs_async_fn_once(x).await;

tests/ui/async-await/async-closures/auxiliary/block-on.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// edition: 2021
22

3-
#![feature(async_closure, noop_waker, async_fn_traits)]
3+
#![feature(async_closure, noop_waker)]
44

55
use std::future::Future;
66
use std::pin::pin;

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

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,18 @@
22
// edition:2021
33
// build-pass
44

5-
#![feature(async_closure, async_fn_traits)]
5+
#![feature(async_closure)]
66

77
extern crate block_on;
88

99
use std::future::Future;
1010
use std::marker::PhantomData;
11-
use std::ops::AsyncFn;
1211

1312
struct S;
1413
struct B<'b>(PhantomData<&'b mut &'b mut ()>);
1514

1615
impl S {
17-
async fn q<F: AsyncFn(B<'_>)>(self, f: F) {
16+
async fn q<F: async Fn(B<'_>)>(self, f: F) {
1817
f(B(PhantomData)).await;
1918
}
2019
}

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

+2-4
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@
33
// run-pass
44
// check-run-results
55

6-
#![feature(async_closure, async_fn_traits)]
6+
#![feature(async_closure)]
77
#![allow(unused)]
88

99
extern crate block_on;
1010

11-
use std::ops::AsyncFnOnce;
12-
1311
struct DropMe(i32);
1412

1513
impl Drop for DropMe {
@@ -18,7 +16,7 @@ impl Drop for DropMe {
1816
}
1917
}
2018

21-
async fn call_once(f: impl AsyncFnOnce()) {
19+
async fn call_once(f: impl async FnOnce()) {
2220
println!("before call");
2321
let fut = Box::pin(f());
2422
println!("after call");

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

+3-4
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,19 @@
88
// FIXME(async_closures): When `fn_sig_for_fn_abi` is fixed, remove this.
99
// ignore-pass (test emits codegen-time warnings)
1010

11-
#![feature(async_closure, noop_waker, async_fn_traits)]
11+
#![feature(async_closure, noop_waker)]
1212

1313
extern crate block_on;
1414

1515
use std::future::Future;
16-
use std::ops::{AsyncFnMut, AsyncFnOnce};
1716
use std::pin::pin;
1817
use std::task::*;
1918

20-
async fn call_mut(f: &mut impl AsyncFnMut()) {
19+
async fn call_mut(f: &mut impl async FnMut()) {
2120
f().await;
2221
}
2322

24-
async fn call_once(f: impl AsyncFnOnce()) {
23+
async fn call_once(f: impl async FnOnce()) {
2524
f().await;
2625
}
2726

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

+3-5
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,15 @@
22

33
// FIXME(async_closures): This needs a better error message!
44

5-
#![feature(async_closure, async_fn_traits)]
6-
7-
use std::ops::AsyncFn;
5+
#![feature(async_closure)]
86

97
fn main() {
10-
fn needs_async_fn(_: impl AsyncFn()) {}
8+
fn needs_async_fn(_: impl async Fn()) {}
119

1210
let mut x = 1;
1311
needs_async_fn(async || {
1412
//~^ ERROR i16: ops::async_function::internal_implementation_detail::AsyncFnKindHelper<i8>
15-
// FIXME: Should say "closure is AsyncFnMut but it needs AsyncFn" or sth.
13+
// FIXME: Should say "closure is `async FnMut` but it needs `async Fn`" or sth.
1614
x += 1;
1715
});
1816
}

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
error[E0277]: the trait bound `i16: ops::async_function::internal_implementation_detail::AsyncFnKindHelper<i8>` is not satisfied
2-
--> $DIR/wrong-fn-kind.rs:13:20
2+
--> $DIR/wrong-fn-kind.rs:11:20
33
|
44
LL | needs_async_fn(async || {
55
| _____--------------_^
66
| | |
77
| | required by a bound introduced by this call
88
LL | |
9-
LL | | // FIXME: Should say "closure is AsyncFnMut but it needs AsyncFn" or sth.
9+
LL | | // FIXME: Should say "closure is `async FnMut` but it needs `async Fn`" or sth.
1010
LL | | x += 1;
1111
LL | | });
1212
| |_____^ the trait `ops::async_function::internal_implementation_detail::AsyncFnKindHelper<i8>` is not implemented for `i16`
1313
|
1414
note: required by a bound in `needs_async_fn`
15-
--> $DIR/wrong-fn-kind.rs:10:31
15+
--> $DIR/wrong-fn-kind.rs:8:31
1616
|
17-
LL | fn needs_async_fn(_: impl AsyncFn()) {}
18-
| ^^^^^^^^^ required by this bound in `needs_async_fn`
17+
LL | fn needs_async_fn(_: impl async Fn()) {}
18+
| ^^^^^^^^^^ required by this bound in `needs_async_fn`
1919

2020
error: aborting due to 1 previous error
2121

0 commit comments

Comments
 (0)