Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Closed
c410-f3r opened this issue May 6, 2022 · 2 comments
Closed
Labels
A-async-await Area: Async & Await T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@c410-f3r
Copy link
Contributor

c410-f3r commented May 6, 2022

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.

@aliemjay
Copy link
Member

aliemjay commented May 6, 2022

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

@rustbot rustbot added A-async-await Area: Async & Await T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 6, 2022
@c410-f3r
Copy link
Contributor Author

c410-f3r commented May 6, 2022

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

@c410-f3r c410-f3r closed this as completed May 6, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-async-await Area: Async & Await T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants