{"action":"created","issue":{"url":"https://api.github.com/repos/crabtw/rust-bindgen/issues/255","repository_url":"https://api.github.com/repos/crabtw/rust-bindgen","labels_url":"https://api.github.com/repos/crabtw/rust-bindgen/issues/255/labels{/name}","comments_url":"https://api.github.com/repos/crabtw/rust-bindgen/issues/255/comments","events_url":"https://api.github.com/repos/crabtw/rust-bindgen/issues/255/events","html_url":"https://github.com/crabtw/rust-bindgen/issues/255","id":127048391,"number":255,"title":"error: unsupported representation for univariant enum","user":{"login":"japaric","id":5018213,"avatar_url":"https://avatars.githubusercontent.com/u/5018213?v=3","gravatar_id":"","url":"https://api.github.com/users/japaric","html_url":"https://github.com/japaric","followers_url":"https://api.github.com/users/japaric/followers","following_url":"https://api.github.com/users/japaric/following{/other_user}","gists_url":"https://api.github.com/users/japaric/gists{/gist_id}","starred_url":"https://api.github.com/users/japaric/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/japaric/subscriptions","organizations_url":"https://api.github.com/users/japaric/orgs","repos_url":"https://api.github.com/users/japaric/repos","events_url":"https://api.github.com/users/japaric/events{/privacy}","received_events_url":"https://api.github.com/users/japaric/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2016-01-16T19:46:25Z","updated_at":"2016-03-10T12:59:12Z","closed_at":null,"body":"Given a header file contains a single variant enum:\r\n\r\n``` C\r\n// snip from /usr/include/cuda.h\r\ntypedef enum CUipcMem_flags_enum {\r\n    CU_IPC_MEM_LAZY_ENABLE_PEER_ACCESS = 0x1 /**< Automatically enable peer access between remote devices as needed */\r\n} CUipcMem_flags;\r\n```\r\n\r\nbindgen produces a non-compilable module:\r\n\r\n``` rust\r\n/* automatically generated by rust-bindgen */\r\n\r\n#[derive(Clone, Copy)]\r\n#[repr(u32)]\r\npub enum Enum_CUipcMem_flags_enum { CU_IPC_MEM_LAZY_ENABLE_PEER_ACCESS = 1, }\r\npub type CUipcMem_flags = Enum_CUipcMem_flags_enum;\r\n```\r\n\r\nThat errors with:\r\n\r\n``` rust\r\ntest.rs:5:1: 5:78 error: unsupported representation for univariant enum [E0083]\r\ntest.rs:5 pub enum Enum_CUipcMem_flags_enum { CU_IPC_MEM_LAZY_ENABLE_PEER_ACCESS = 1, }\r\n          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\ntest.rs:5:1: 5:78 help: run `rustc --explain E0083` to see a detailed explanation\r\nerror: aborting due to previous error\r\n```\r\n\r\n---\r\n\r\nA possible solution to make bindgen generate a valid module in this case, is to follow the recommendation of `rustc --explain E0083`:\r\n\r\n```\r\nAt present, it's not possible to define a custom representation for an enum with\r\na single variant. As a workaround you can add a `Dummy` variant.\r\n\r\nSee: https://github.com/rust-lang/rust/issues/10292\r\n```\r\n\r\nAnd have bindgen add a `__DUMMY` variant to the translated single-variant enum.\r\n\r\nDoes that sound like a reasonable solution?\r\n\r\ncc @nox"},"comment":{"url":"https://api.github.com/repos/crabtw/rust-bindgen/issues/comments/194831440","html_url":"https://github.com/crabtw/rust-bindgen/issues/255#issuecomment-194831440","issue_url":"https://api.github.com/repos/crabtw/rust-bindgen/issues/255","id":194831440,"user":{"login":"nox","id":123095,"avatar_url":"https://avatars.githubusercontent.com/u/123095?v=3","gravatar_id":"","url":"https://api.github.com/users/nox","html_url":"https://github.com/nox","followers_url":"https://api.github.com/users/nox/followers","following_url":"https://api.github.com/users/nox/following{/other_user}","gists_url":"https://api.github.com/users/nox/gists{/gist_id}","starred_url":"https://api.github.com/users/nox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nox/subscriptions","organizations_url":"https://api.github.com/users/nox/orgs","repos_url":"https://api.github.com/users/nox/repos","events_url":"https://api.github.com/users/nox/events{/privacy}","received_events_url":"https://api.github.com/users/nox/received_events","type":"User","site_admin":false},"created_at":"2016-03-10T12:59:12Z","updated_at":"2016-03-10T12:59:12Z","body":"We should rather implement a flag that lets it disable Rust enums for C enums."}}