-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Univariant enums cannot have repr set #10292
Comments
The bug is that univariant enums are allowed no representation whatsoever, they seem to be forced to 1-byte. (Updating issue title to reflect this) |
ping @jld |
Nominating, seems important for FFI. Is backwards compatible, though. |
Assigning P-high, not a 1.0 issue. |
CC Me |
stepancheg
added a commit
to stepancheg/rust
that referenced
this issue
Jan 27, 2016
``` #[repr(i32)] enum Univariant { X = 17 } ``` Fixes rust-lang#10292
bors
added a commit
that referenced
this issue
Feb 1, 2016
``` enum Univariant { X = 17 } ``` Fixes #10292
flip1995
pushed a commit
to flip1995/rust
that referenced
this issue
Feb 10, 2023
…ump, r=flip1995 Make `[clippy::dump]` support trait items Roses are red, violets are blue, trait items are rare, `[clippy::dump]` is too --- Let's just ignore the horrible poem... anyways. While working on Marker I noticed, that `[clippy::dump]` doesn't work on trait item (See [Playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=e2d9791ffa2872e7c09a9dfbd470350c)). This simply adds support for that. `[clippy::dump]` doesn't have UI tests, to make it more resistant to changes in the AST. I tested it locally and the dump works after these changes. --- changelog: none
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In writing bindings for C libraries which feature enums in their API, single-variant enums can and do occur. However, binding these by generating a matching Rust enum with only one variant is not currently possible, as rustc gives
error: unsupported representation for univariant enum
on code like
Currently this can be worked-around by adding a dummy variant as shown, but that shouldn't be necessary as it requires handling in consumer code, e.g. matches.
CC @jld who added the very very useful ability to use
#[repr(C)]
in the first place. :)The text was updated successfully, but these errors were encountered: