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

Async struct method, <_'> lifetime shadowing #64630

Closed
fominok opened this issue Sep 20, 2019 · 3 comments · Fixed by #65142
Closed

Async struct method, <_'> lifetime shadowing #64630

fominok opened this issue Sep 20, 2019 · 3 comments · Fixed by #65142
Assignees
Labels
A-async-await Area: Async & Await A-lifetimes Area: Lifetimes / regions AsyncAwait-Polish Async-await issues that are part of the "polish" area C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@fominok
Copy link

fominok commented Sep 20, 2019

Hello, I ran into a problem using <'_> lifetime with async struct methods, here is the example:

struct Foo<'a> { swag: &'a i32 }

impl Foo<'_> {
    async fn bar(&self) -> i32 {
        1337
    }
}

The error is:
error[E0496]: lifetime name '_ shadows a lifetime name that is already in scope

Everything is fine if I use explicit lifetime like 'a.

Version: 1.39 Nighly (2019-09-19 9b9d2af on playground)

@jonas-schievink jonas-schievink added A-async-await Area: Async & Await A-lifetimes Area: Lifetimes / regions AsyncAwait-Unclear C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 20, 2019
@matthewjasper matthewjasper self-assigned this Sep 22, 2019
@cramertj cramertj added AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. and removed AsyncAwait-Unclear labels Sep 24, 2019
@cramertj
Copy link
Member

This is happening because the desugaring of async fn uses the '_ lifetime. This is sort of unfortunate, but seems backwards compatible to fix, so I don't think we should block on this.

@nikomatsakis nikomatsakis added AsyncAwait-OnDeck AsyncAwait-Polish Async-await issues that are part of the "polish" area and removed AsyncAwait-OnDeck AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. labels Oct 1, 2019
@nikomatsakis
Copy link
Contributor

We decided to focus on this one in the WG meeting -- @matthewjasper you still interested in working on it?

@matthewjasper
Copy link
Contributor

Yes, I'm still interested in working on this. I don't think that this should be too hard to fix though if someone else wants it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-async-await Area: Async & Await A-lifetimes Area: Lifetimes / regions AsyncAwait-Polish Async-await issues that are part of the "polish" area C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants