Skip to content

Commit

Permalink
Add a couple more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Feb 8, 2024
1 parent 3bb384a commit 9322882
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/ui/async-await/async-closures/once.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// aux-build:block-on.rs
// edition:2021
// build-pass

#![feature(async_closure)]

use std::future::Future;

extern crate block_on;

struct NoCopy;

fn main() {
block_on::block_on(async {
async fn call_once<F: Future>(x: impl Fn(&'static str) -> F) -> F::Output {
x("hello, world").await
}
call_once(async |x: &'static str| {
println!("hello, {x}");
}).await
});
}
18 changes: 18 additions & 0 deletions tests/ui/async-await/async-closures/refd.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// aux-build:block-on.rs
// edition:2021
// build-pass

// check that `&{async-closure}` implements `AsyncFn`.

#![feature(async_closure)]

extern crate block_on;

struct NoCopy;

fn main() {
block_on::block_on(async {
async fn call_once(x: impl async Fn()) { x().await }
call_once(&async || {}).await
});
}

0 comments on commit 9322882

Please sign in to comment.