Also support fnptr(): async Fn
in codegen
This commit is contained in:
parent
4c0016a01f
commit
2252ff7302
2 changed files with 36 additions and 1 deletions
31
tests/ui/async-await/async-fn/higher-ranked-async-fn.rs
Normal file
31
tests/ui/async-await/async-fn/higher-ranked-async-fn.rs
Normal file
|
@ -0,0 +1,31 @@
|
|||
//@ aux-build:block-on.rs
|
||||
//@ edition:2018
|
||||
//@ revisions: current next
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
//@ build-pass (since it ICEs during mono)
|
||||
|
||||
#![feature(async_closure)]
|
||||
|
||||
extern crate block_on;
|
||||
|
||||
use std::future::Future;
|
||||
|
||||
async fn f(arg: &i32) {}
|
||||
|
||||
async fn func<F>(f: F)
|
||||
where
|
||||
F: async for<'a> Fn(&'a i32),
|
||||
{
|
||||
let x: i32 = 0;
|
||||
f(&x).await;
|
||||
}
|
||||
|
||||
fn main() {
|
||||
block_on::block_on(async {
|
||||
// Function
|
||||
func(f).await;
|
||||
|
||||
// Regular closure (doesn't capture)
|
||||
func(|x: &i32| async {});
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue