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

Self:: needs to be handled in tuple and struct variant paths #87

Closed
dtolnay opened this issue Apr 2, 2020 · 0 comments · Fixed by #88
Closed

Self:: needs to be handled in tuple and struct variant paths #87

dtolnay opened this issue Apr 2, 2020 · 0 comments · Fixed by #88
Labels
bug Something isn't working

Comments

@dtolnay
Copy link
Owner

dtolnay commented Apr 2, 2020

use async_trait::async_trait;

#[async_trait]
pub trait Trait {
    async fn f(&self);
}

pub enum Tuple {
    V(),
}

pub enum Struct {
    V {},
}

#[async_trait]
impl Trait for Tuple {
    async fn f(&self) {
        let Tuple::V() = self; // works
        let Self::V() = self; // does not work
    }
}

#[async_trait]
impl Trait for Struct {
    async fn f(&self) {
        let Struct::V {} = self; // works
        let Self::V {} = self; // does not work
    }
}
error[E0401]: can't use generic parameters from outer function
   --> tests/test.rs:609:17
    |
606 |     impl Trait for Tuple {
    |     ---- `Self` type implicitly declared here, by this `impl`
...
609 |             let Self::V() = self;
    |                 ^^^^^^^
    |                 |
    |                 use of generic parameter from outer function
    |                 use a type here instead

error[E0401]: can't use generic parameters from outer function
   --> tests/test.rs:617:17
    |
614 |     impl Trait for Struct {
    |     ---- `Self` type implicitly declared here, by this `impl`
...
617 |             let Self::V {} = self;
    |                 ^^^^^^^
    |                 |
    |                 use of generic parameter from outer function
    |                 use a type here instead
@dtolnay dtolnay added the bug Something isn't working label Apr 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant