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:: doesn't work in patterns #81

Closed
dtolnay opened this issue Apr 1, 2020 · 0 comments · Fixed by #82
Closed

Self:: doesn't work in patterns #81

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

Comments

@dtolnay
Copy link
Owner

dtolnay commented Apr 1, 2020

use async_trait::async_trait;

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

pub enum Enum {
    Variant,
}

#[async_trait]
impl Trait for Enum {
    async fn handle(&self) {
        let Enum::Variant = self; // works
        let Self::Variant = self; // does not work
    }
}
error[E0401]: can't use generic parameters from outer function
   --> tests/test.rs:552:17
    |
549 |     impl Trait for Enum {
    |     ---- `Self` type implicitly declared here, by this `impl`
...
552 |             let Self::Variant = self;
    |                 ^^^^^^^^^^^^^
    |                 |
    |                 use of generic parameter from outer function
    |                 use a type here instead
@dtolnay dtolnay added the bug Something isn't working label Apr 1, 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