Merge pull request #18594 from ChayimFriedman2/async-closures

feat: Support `AsyncFnX` traits
This commit is contained in:
Lukas Wirth 2024-12-06 12:48:47 +00:00 committed by GitHub
commit abc7147bb7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 289 additions and 66 deletions

View file

@ -37,4 +37,25 @@ fn foo() {
"#,
);
}
#[test]
fn no_error_for_async_fn_traits() {
check_diagnostics(
r#"
//- minicore: async_fn
async fn f(it: impl AsyncFn(u32) -> i32) {
let fut = it(0);
let _: i32 = fut.await;
}
async fn g(mut it: impl AsyncFnMut(u32) -> i32) {
let fut = it(0);
let _: i32 = fut.await;
}
async fn h(it: impl AsyncFnOnce(u32) -> i32) {
let fut = it(0);
let _: i32 = fut.await;
}
"#,
);
}
}