rust-lang / rust-lang/rust-bindgen
Private padding and alignment fields + missing Defaut/Clone/Copy implementations
Open
Nobody has claimed this yet.
I-needs-reduced-test-case
- Dominant language
- Rust
- Stars
- 5.3k
- Forks
- 829
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 15
Description
Input C/C++ Header
// libfuse fetched using pkg_config
// Generating bindings for 'fuse.h'
Bindgen Invocation
bindgen::builder()
// Add clang flags
.clang_args(compile_flags)
// Derive Debug, Copy and Default
.derive_default(true)
.derive_copy(true)
.derive_debug(true)
// Add CargoCallbacks so build.rs is rerun on header changes
.parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
// Whitelist "fuse_*" symbols and blocklist everything else
.allowlist_recursively(false)
.allowlist_type("[fF][uU][sS][eE].*")
.allowlist_function("[fF][uU][sS][eE].*")
.allowlist_var("[fF][uU][sS][eE].*")
.blocklist_type("fuse_log_func_t")
.blocklist_function("fuse_set_log_func");
// Let's generate!
.header(header_path)
.generate()
.unwrap_or_else(|_| panic!("Failed to generate {} bindings", header))
Actual Results
// Extract of the generated bindings file
pub struct stat {
pub st_dev: ::dev_t,
pub st_ino: ::ino_t,
pub st_nlink: ::nlink_t,
pub st_mode: ::mode_t,
pub st_uid: ::uid_t,
pub st_gid: ::gid_t,
__pad0: ::c_int,
pub st_rdev: ::dev_t,
pub st_size: ::off_t,
pub st_blksize: ::blksize_t,
pub st_blocks: ::blkcnt_t,
pub st_atime: ::time_t,
pub st_atime_nsec: i64,
pub st_mtime: ::time_t,
pub st_mtime_nsec: i64,
pub st_ctime: ::time_t,
pub st_ctime_nsec: i64,
__unused: [i64; 3],
}
Expected Results
- Both
__pad0and__unusedshould be marked aspub - Derives for
Default,CloneandCopyare missing
The same problems occur on many other structs.
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 issue against libfuse's fuse.h using the shown bindgen builder options, then trace how allowlisted C/C++ structs receive field visibility and derives. Done means padding fields such as __pad0 and __unused are public and affected structs receive Default, Clone, and Copy derives.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100