Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect type hints for async closures (nightly feature async_closure). #12957

Closed
zachs18 opened this issue Aug 7, 2022 · 0 comments · Fixed by #12958
Closed

Incorrect type hints for async closures (nightly feature async_closure). #12957

zachs18 opened this issue Aug 7, 2022 · 0 comments · Fixed by #12958

Comments

@zachs18
Copy link
Contributor

zachs18 commented Aug 7, 2022

Rust-analyzer shows incorrect type hints for async closures (nightly feature, tracking issue).

#![feature(async_closure)]
pub async fn test_async_closure() {
    let f = async move |num: u8| num + 1;
    let fut = f(3);
    let output = fut.await;
}
pub async fn test_closure_returning_async_block() {
    let f = |num: u8| async move {num + 1};
    let fut = f(3);
    let output = fut.await;
}

RA gives following the inlay hints:

pub async fn test_async_closure() { // Incorrect
    let f: |u8| -> u8 = async move |num: u8| num + 1;
    let fut: u8 = f(3);
    let output: <u8 as Future>::Output = fut.await;
}
pub async fn test_closure_returning_async_block() { // Correct
    let f: |u8| -> impl Future<Output = u8> = |num: u8| async move {num + 1};
    let fut: impl Future<Output = u8> = f(3);
    let output: u8 = fut.await;
}

(No type errors are given, despite u8: !Future)

The inlay hints for test_async_closure should be the same as test_closure_returning_async_block.


rust-analyzer version: rust-analyzer version: 0.4.1159-standalone (3792720 2022-08-05)
Also happens on current HEAD

rustc version: rustc 1.64.0-nightly (1b57946a4 2022-08-03)

relevant settings: None that I am aware are relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant