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

"No variant named VariantName" when using Self::Variant syntax #55157

Closed
cramertj opened this issue Oct 17, 2018 · 3 comments
Closed

"No variant named VariantName" when using Self::Variant syntax #55157

cramertj opened this issue Oct 17, 2018 · 3 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@cramertj
Copy link
Member

enum Foo {
    Bar
}

impl Foo {
    fn foo() -> Self {
        Self::Bar
    }
}

gives the error

error[E0599]: no variant named `Bar` found for type `Foo` in the current scope
 --> src/main.rs:7:9
  |
1 | enum Foo {
  | -------- variant `Bar` not found here
...
7 |         Self::Bar
  |         ^^^^^^^^^ variant not found in `Foo`
  |
  = note: did you mean `Foo::Bar`?

error: aborting due to previous error

The "variant not found" bit is nonsense.

@cramertj cramertj added the A-diagnostics Area: Messages for errors, warnings, and lints label Oct 17, 2018
@Centril
Copy link
Contributor

Centril commented Oct 17, 2018

cc #49683

@estebank
Copy link
Contributor

Latest output:

error: enum variants on type aliases are experimental
 --> file.rs:7:9
  |
7 |         Self::Bar
  |         ^^^^^^^^^
  |
  = help: add `#![feature(type_alias_enum_variants)]` to the crate attributes to enable

@cramertj cramertj closed this as completed Jan 2, 2019
@cramertj
Copy link
Member Author

cramertj commented Jan 2, 2019

Based on @estebank's comment, this seems to be resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints
Projects
None yet
Development

No branches or pull requests

3 participants