rust-lang / rust-lang/rust-bindgen
rustified_enum doesn't work with anonymous enums
Open
Nobody has claimed this yet.
A-enums
- Dominant language
- Rust
- Stars
- 5.3k
- Forks
- 829
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 15
Description
Input C/C++ Header
https://github.com/llvm-mirror/llvm/blob/master/include/llvm/IR/CallingConv.h
Bindgen Invocation
bindgen::Builder::default()
.header("llvm/IR/CallingConv.h")
.whitelisted_type("llvm::CallingConv.*")
.rustified_enum("llvm::CallingConv.*")
.generate()
.unwrap()
.write_to_file("bindings.rs")
.unwrap();
Actual Results
/// LLVM IR allows to use arbitrary numbers as calling convention identifiers.
pub type llvm_CallingConv_ID = :: std :: os :: raw :: c_uint ; pub const C : llvm_CallingConv__bindgen_ty_1 = 0 ;
pub const Fast : llvm_CallingConv__bindgen_ty_1 = 8 ;
pub const Cold : llvm_CallingConv__bindgen_ty_1 = 9 ;
pub const GHC : llvm_CallingConv__bindgen_ty_1 = 10;
pub const HiPE : llvm_CallingConv__bindgen_ty_1 = 11 ;
pub const WebKit_JS : llvm_CallingConv__bindgen_ty_1 = 12 ;
pub const AnyReg : llvm_CallingConv__bindgen_ty_1 = 13 ;
pub const PreserveMost : llvm_CallingConv__bindgen_ty_1 = 14 ;
pub const PreserveAll : llvm_CallingConv__bindgen_ty_1 = 15 ;
pub const Swift : llvm_CallingConv__bindgen_ty_1 = 16 ;
pub const CXX_FAST_TLS : llvm_CallingConv__bindgen_ty_1 = 17 ;
pub const FirstTargetCC : llvm_CallingConv__bindgen_ty_1 = 64 ;
pub const X86_StdCall : llvm_CallingConv__bindgen_ty_1 = 64 ;
pub const X86_FastCall : llvm_CallingConv__bindgen_ty_1 = 65 ;
pub const ARM_APCS : llvm_CallingConv__bindgen_ty_1 = 66 ;
...
pub const MaxID : llvm_CallingConv__bindgen_ty_1 = 1023 ;
pub type llvm_CallingConv__bindgen_ty_1 = :: std :: os :: raw :: c_uint ;
Expected Results
A Rust enum resembling:
pub enum LLVMRustResult { Success = 0 , Failure = 1 , }
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the bindgen::Builder invocation against llvm/IR/CallingConv.h and inspect the generated bindings.rs. Start with how rustified_enum handles the anonymous enum represented by llvm::CallingConv, then compare the output with the expected Rust enum form. Done means anonymous enums produce the intended rustified representation instead of constants backed by a generated type alias.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, rust
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100