rust-lang / rust-lang/rust-bindgen
ObjC C-style extra parameters panic (assert_eq on selector arity)
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
__attribute__((objc_root_class))
@interface Foo
- (int)take:(int)t, int extra;
@end
Bindgen Invocation
$ bindgen input.h -- -x objective-c
Actual Results
clang accepts the header with -Wdeprecated-declarations ("use of C-style parameters in Objective-C method declarations is deprecated"). The selector is still take:; libclang reports two ParmDecls.
bindgen aborts:
panicked at bindgen/ir/objc.rs:297:9:
assertion `left == right` failed: Incorrect method name or arguments for objc method
left: 2
right: 1
format_method_call assumes args.len() == selector.split(':').len() - 1. Extra C-style parameters after a comma are in the clang parameter list but not in the selector.
- (int)take:(int)t; does not panic. The #1703 empty-keyword form - (int)take:(int)a :(int)b; also does not panic anymore.
Expected Results
Do not abort. Either emit the extra parameter on the generated method or skip the method.
Environment
bindgen: 0.73.1 (rust-lang/rust-bindgen 77cbc723)
clang/libclang: Homebrew clang 21.1.8
rustc: 1.97.1
target: aarch64-apple-darwin
OS: macOS
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 by reproducing the supplied Objective-C header and bindgen invocation, then read bindgen/ir/objc.rs around format_method_call and the assertion at line 297. Confirm that C-style parameters can outnumber selector components; done means the invocation no longer panics and either emits the extra parameter or skips the method.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- objective-c, rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 70/100