Skip to content

Invalid suggestion to .await on a function argument pattern #126903

Closed
@theemathas

Description

@theemathas

Code

async fn do_async() {}

fn main() {
    Some(do_async()).map(|()| {});
}

Current output

Compiling playground v0.0.1 (/playground)
error[E0308]: mismatched types
 --> src/main.rs:4:27
  |
4 |     Some(do_async()).map(|()| {});
  |                           ^^
  |                           |
  |                           expected future, found `()`
  |                           expected due to this
  |
  = note: expected opaque type `impl Future<Output = ()>`
               found unit type `()`
help: consider `await`ing on the `Future`
  |
4 |     Some(do_async()).map(|().await| {});
  |                             ++++++

For more information about this error, try `rustc --explain E0308`.
error: could not compile `playground` (bin "playground") due to 1 previous error

Desired output

Don't suggest awaiting.

Rationale and extra context

No response

Other cases

No response

Rust Version

Playground's stable rust (1.79.0)

Anything else?

Found by 0xbadbeef_60104 on the official rust discord.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions