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

Enum variant fields are not allowed to be pub, so EnumValue::add_pub_field generates invalid Rust #86

Open
NightEule5 opened this issue Jun 11, 2024 · 0 comments
Labels
bug Something isn't working good first issue Good for newcomers not-stale

Comments

@NightEule5
Copy link
Contributor

NightEule5 commented Jun 11, 2024

When implementing generics, I found an oversight in enum generation:

generator
    .generate_enum("Foo")
    .add_value("Bar")
    .add_pub_field("bar", "u32");

// Generates:
enum Foo {
    Bar {
        pub bar: u32
    }
}

This does not compile, as the variant fields inherit the visibility of their parent enum:

error[E0449]: visibility qualifiers are not permitted here
 --> ...
  |
3 |         pub bar: u32
  |         ^^^
  |
  = note: enum variants and their fields always share the visibility of the enum they are in

This method appears to have been copied over from the struct generator code, as the documentation refers to structs. But it should be removed (or deprecated) from the enum variant code.

@VictorKoenders VictorKoenders added bug Something isn't working good first issue Good for newcomers not-stale labels Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers not-stale
Projects
None yet
Development

No branches or pull requests

2 participants