Skip to content

improve the "must use" lint for Future to suggest await #60797

Closed
@nikomatsakis

Description

@nikomatsakis

The following code gives a "must use" warning (which is awesome!), but the warning is not as clear as it could be:

#![feature(async_await)]
#![allow(dead_code)]

async fn foo() {
    bar();
}

async fn bar() {
}

fn main() { }

This results in:

warning: unused implementer of `std::future::Future` that must be used
 --> src/main.rs:5:5
  |
5 |     bar();
  |     ^^^^^^
  |
  = note: #[warn(unused_must_use)] on by default
  = note: futures do nothing unless polled

it should probably say "futures do nothing unless you await them" or something. Most people won't know what 'polled' is all about, I think.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-async-awaitArea: Async & AwaitA-diagnosticsArea: Messages for errors, warnings, and lintsE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-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