Skip to content

Commit

Permalink
Unrolled build for rust-lang#120713
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#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.
  • Loading branch information
rust-timer authored Feb 6, 2024
2 parents 4a2fe44 + f130878 commit 7a7fbcc
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/async-await/async-closures/auxiliary/block-on.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
5 changes: 2 additions & 3 deletions tests/ui/async-await/async-closures/brand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<F: AsyncFn(B<'_>)>(self, f: F) {
async fn q<F: async Fn(B<'_>)>(self, f: F) {
f(B(PhantomData)).await;
}
}
Expand Down
6 changes: 2 additions & 4 deletions tests/ui/async-await/async-closures/drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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");
Expand Down
7 changes: 3 additions & 4 deletions tests/ui/async-await/async-closures/mangle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
8 changes: 3 additions & 5 deletions tests/ui/async-await/async-closures/wrong-fn-kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<i8>
// 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;
});
}
10 changes: 5 additions & 5 deletions tests/ui/async-await/async-closures/wrong-fn-kind.stderr
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
error[E0277]: the trait bound `i16: ops::async_function::internal_implementation_detail::AsyncFnKindHelper<i8>` 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<i8>` 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

Expand Down

0 comments on commit 7a7fbcc

Please sign in to comment.