rust-lang / rust-lang/rust-bindgen
Inappropriate generated type for function-returning-function
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 5.3k
- Forks
- 829
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 15
Description
Input C/C++ Header
void (*(*xDlSym)(const char *))(void);
Bindgen Invocation
$ bindgen input.h
Actual Results
/* automatically generated by rust-bindgen 0.69.1 */
extern "C" {
pub static mut xDlSym: ::std::option::Option<
unsafe extern "C" fn(
arg3: *const ::std::os::raw::c_char,
) -> ::std::option::Option<
unsafe extern "C" fn(
arg3: *const ::std::os::raw::c_char,
),
>,
>;
}
Expected Results
extern "C" {
pub static mut xDlSym: ::std::option::Option<
unsafe extern "C" fn(
arg3: *const ::std::os::raw::c_char,
) -> ::std::option::Option<
unsafe extern "C" fn(
- arg3: *const ::std::os::raw::c_char,
),
>,
>;
}
The original C signature is hard to read: it describes a function pointer xDlSym that takes a single const char * argument and returns another function pointer of type void (*)(void). But in the bindgen-generated output, the returned function pointer has the inappropriate type void (*)(const char *) instead.
This affects the public API of libsqlite3-sys here; the reproducer is minimized from that situation.
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
Start with the minimal input.h declaration and run the bindgen invocation shown in the issue to reproduce the generated Rust type. Compare the returned function pointer's parameter list with the expected output and add coverage for this function-returning-function case; done when the generated binding matches the expected signature.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, cpp, rust
- Domain
- compilers, devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100