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

Comments

@fominok
Copy link

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)

@cramertj

This comment has been minimized.

Copy link
Member

commented Sep 24, 2019

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

This comment has been minimized.

Copy link
Contributor

commented Oct 1, 2019

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

@matthewjasper

This comment has been minimized.

Copy link
Contributor

commented Oct 1, 2019

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
Projects
None yet
5 participants
You can’t perform that action at this time.