Skip to content

Hidden type for impl Trait captures lifetime that does not appear in bounds #96771

Closed

Description

@c410-f3r
rustc 1.62.0-nightly (30f386087 2022-05-05)

Yet another problem related to 'static and async but this time impl Trait is involved somehow. Funny enough, the error goes away when the number of arguments is decreased to 2 instead of 3.

// Try removing one argument to successfully compile
async fn foo(
  a: &'static i32,
  b: &i32,
  c: &i32,
) -> Option<&'static i32> {
  None
}

It is worth noting that a different error arises when the return is not 'static.

Activity

  1. aliemjay commented on May 6, 2022

    @aliemjay
    Contributor

    This is #63033.

    A workaround exists that shouldn't change the semantics of the function:

    async fn foo<'a>(
      a: &'static i32,
      b: &'a i32,
      c: &'a i32,
    ) -> Option<&'static i32> {
      None
    }

    @rustbot label T-compiler A-async_await C-bug

  2. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on May 6, 2022
  3. c410-f3r commented on May 6, 2022

    @c410-f3r
    ContributorAuthor

    Oh, this is indeed #63033. I could swear the error message was different, my bad.

    Closing as duplicated but the the successful compilation of 2 or less arguments is still a bit strange

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-async-awaitArea: Async & AwaitT-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