rust-lang / rust-lang/rust-bindgen

ObjC selector with $ panics ("take$foo" is not a valid Ident)

Open Beginner friendly
#3,483 0 comments 0 reactions 0 assignees View on GitHub

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$foo:(int)t;
@end
Bindgen Invocation
$ bindgen input.h -- -x objective-c
Actual Results

bindgen aborts:

panicked at bindgen/ir/objc.rs:264:30:
"take$foo" is not a valid Ident

clang accepts $ in the selector. C names with $ already go through rust_mangle ($_). ObjC format_method_call passes selector fragments to Ident::new / syn::parse_str without that.

This is not #2486 (keyword type / self) or #1703 (empty :: fragments).

Expected Results

Do not abort. Mangle $ in selector fragments the same way C identifiers are mangled.

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in bindgen/ir/objc.rs at format_method_call and the panic reported around line 264. Reproduce the issue with the provided Objective-C header and bindgen invocation, then verify that selector fragments containing $ no longer abort and are mangled consistently with the expected output.

Written by the indexing model from the issue text.

Assessment

Tech stack
objective-c, rust
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.