Skip to content

Confusing diagnostic when use Self::Variant inside an impl #111627

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

Closed
fee1-dead opened this issue May 16, 2023 · 0 comments · Fixed by #111652
Closed

Confusing diagnostic when use Self::Variant inside an impl #111627

fee1-dead opened this issue May 16, 2023 · 0 comments · Fixed by #111652
Labels
A-diagnostics Area: Messages for errors, warnings, and lints D-confusing Diagnostics: Confusing error or lint that should be reworked.

Comments

@fee1-dead
Copy link
Member

I tried this (play):

pub enum Uwu {
    Hi
}

impl Uwu {
    fn a() -> Uwu {
        use Self::Hi;
        Hi
    }
}

Heres the current output:

   Compiling playground v0.0.1 (/playground)
error[E0432]: unresolved import `Self`
 --> src/lib.rs:8:13
  |
8 |         use Self::Hi;
  |             ^^^^ `Self` is only available in impls, traits, and type definitions

For more information about this error, try `rustc --explain E0432`.
error: could not compile `playground` due to previous error

The label that says "Self is only available in impls" is misleading since it is already in an impl.

@fee1-dead fee1-dead added A-diagnostics Area: Messages for errors, warnings, and lints D-confusing Diagnostics: Confusing error or lint that should be reworked. labels May 16, 2023
@bors bors closed this as completed in 13f3585 May 20, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints D-confusing Diagnostics: Confusing error or lint that should be reworked.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant