Skip to content

error[E0391]: cycle detected when computing type of async fn #78649

Open
@Diggsey

Description

I tried this code:

use futures::future::FutureExt;

async fn foo() {
    FutureExt::boxed(async {
        foo().await;
    });
}

https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=19653eea2af1dd97a8d48126dfd7d683

I expected it to compile, but it gave the following error:

error[E0391]: cycle detected when computing type of foo::{{opaque}}#0

edit:
With one minor change, it compiles:

async fn foo() {
    Box::new(async {
        foo().await;
    });
}

There are no rules that would explain why the first should fail when this succeeds.

Metadata

Assignees

No one assigned

    Labels

    A-async-awaitArea: Async & AwaitA-diagnosticsArea: Messages for errors, warnings, and lintsA-type-systemArea: Type systemAsyncAwait-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.T-typesRelevant to the types team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    • Status

      On deck

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions