Skip to content

objc: Don't panic on Objective-C methods with C-style parameters - #3524

Merged
emilio merged 1 commit into
rust-lang:mainfrom
GBra-4-669:objc-c-style-params
Oct 16, 2026
Merged

emilio merged 1 commit into
rust-lang:mainfrom
GBra-4-669:objc-c-style-params

Conversation

@GBra-4-669

Copy link
Copy Markdown
Contributor

Fixes #3488.

An Objective-C method that declares C-style parameters is accepted by clang, with
-Wdeprecated-declarations:

- (int)take:(int)t, int extra;

Both parameters land in clang's parameter list, but the selector is still take:. format_method_call
asserted that the two counts agreed. bindgen aborted:

panicked at bindgen/ir/objc.rs:297:9:
assertion `left == right` failed: Incorrect method name or arguments for objc method

msg_send! dispatches on the selector. A method with a parameter count that disagrees with its selector
cannot be represented and emitting it would produce a call with the wrong argument list.
Skip the method and warn instead of aborting.
The crate already does this for other constructs it cannot support (ir/var.rs).

The output for valid Objective-C is unchanged. Across the 19 objc*.h test headers, 18 produce
byte-identical output. The only difference is objc_c_style_params.h, which previously aborted
(exit 101) and now succeeds (exit 0).

Two extra things:

  • With the logging feature off, warn! emits nothing. A skipped method is dropped silently.
  • The warning names the selector but not the owning class. The same selector declared in two places
    produces two identical warnings.

cargo test -p bindgen-tests: 638 passed, 2 failed. Both fail identically on the base commit.

@emilio emilio left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@emilio
emilio added this pull request to the merge queue Oct 16, 2026
Merged via the queue into rust-lang:main with commit f08d4ff Oct 16, 2026
52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ObjC C-style extra parameters panic (assert_eq on selector arity)

2 participants