Support AsyncFnX traits

Only in calls, because to support them in bounds we need support from Chalk. However we don't yet report error from bounds anyway, so this is less severe.

The returned future is shown in its name within inlay hints instead of as a nicer `impl Future`, but that can wait for another PR.
This commit is contained in:
Chayim Refael Friedman 2024-12-03 20:46:45 +02:00
parent e6276c8b64
commit 4049c3b6a9
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;
}
"#,
);
}
}