Skip to content

unreachable_code warning when invoke .await on async diverging function #61798

Closed
@nextzhou

Description

@nextzhou

I tried this code:

async fn foo() {
    endless().await;
}

async fn endless() -> ! {
    loop {}
}

I expected to see this happen: no build warn

Instead, this happened:

warning: unreachable expression
 --> src/main.rs:8:5
  |
8 |     endless().await;
  |     ^^^^^^^^^^^^^^^
  |
  = note: #[warn(unreachable_code)] on by default

Meta

rustc --version --verbose:

rustc 1.37.0-nightly (5f3656ce9 2019-06-11)
binary: rustc
commit-hash: 5f3656ce9a2212fad872605b7a4ee103a155e9f3
commit-date: 2019-06-11
host: x86_64-unknown-linux-gnu
release: 1.37.0-nightly
LLVM version: 8.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-async-awaitArea: Async & AwaitA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.AsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.C-bugCategory: This is a bug.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