Skip to content

Futures involving uninhabited variables are incorrectly considered uninhabited. #59972

@Lymia

Description

@Lymia

The following code crashes with an illegal instruction, presumably because all the code after contains_never is considered unreachable:

#![feature(futures_api, async_await, await_macro)]

pub enum Uninhabited { }

fn uninhabited_async() -> Uninhabited {
    unreachable!()
}

async fn noop() { }

async fn contains_never() {
    let error = uninhabited_async();
    await!(noop());
    let error2 = error;
}

fn main() {
    contains_never();
}

It seems the root cause is that the struct representing the future contains a field of type Uninhabited as it is preserved across the (unreachable) yield point and thus is considered uninhabited itself, despite being perfectly constructible.

Metadata

Metadata

Assignees

Labels

A-async-awaitArea: Async & AwaitAsyncAwait-PolishAsync-await issues that are part of the "polish" areaC-bugCategory: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessP-highHigh priorityT-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