Skip to content

"unsupported representation for univariant enum" when using the repr attribute with single-variant enums #12371

Closed
@bstrie

Description

@bstrie

Reproduce:

#[repr(u8)] enum Bar { Foo }
fn main() {}

Error:

repr.rs:1:13: 1:29 error: unsupported representation for univariant enum
repr.rs:1 #[repr(u8)] enum Bar { Foo }
                      ^~~~~~~~~~~~~~~~
error: aborting due to previous error

@cmr was convinced that this ought to be fixed. #rust also produced an example of where this would be necessary, from GLib:

typedef enum {
    G_THREAD_ERROR_AGAIN /* Resource temporarily unavailable */
} GThreadError;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions