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

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

Open
nextzhou opened this issue Jun 13, 2019 · 3 comments

Comments

Projects
None yet
4 participants
@nextzhou
Copy link

commented Jun 13, 2019

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
@nikomatsakis

This comment has been minimized.

Copy link
Contributor

commented Jun 25, 2019

We discussed this a bit on Zulip. The likely cause is that parts of the await desugaring are being linted against. We can likely check the span to see if the code that is being linted against is part of the .await desugaring, but we do want to be careful to ensure that

async fn foo() {
    return; bar().await;
}

async fn bar() {
}

still gets a lint warning.

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

commented Jun 25, 2019

Marking as deferred as this doesn't seem like a problem that needs to block stabilization.

@Centril

This comment has been minimized.

Copy link
Member

commented Jun 25, 2019

cc @varkor who has done some work on the inhabited logic stuff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.